Skip to content

Tag: mysql

Update column, replace part of value

I’m trying to replace a specific piece of text. I have no experience at all with mysql. The table (content) has a column ( keywords ) containing all kind of words separated by comma. I want to replace tekst with text. Important: the whole string contains many other combined values with partly tekst in i…

Select ans specific value or, if not exists, the minimum one

I’m stuck trying to solve a problem using SQL (MySQL 5.6). Need to get the address which has ID 2 or, if not exists ID 2, the lower ID. For example If a costumerID have an AddressID 2, must get that. If not, must get the minimum AddressID. The output must be like: So far I’ve tried this: but get

mysql get result from join table

I have a tables person and exam. I want to show data where all exam is PASS, show the latest exam pass_date. like table below what query to get it? please help. thanks! Answer You can use aggregation and conditional expressions: Note that for this sample data, you don’t need to bring in the person table…

MySql query to check list of ids if they are friends with me?

So I have a list of ids(userId’s) that was found using a sql command that I want to check with my friends table to see if they are indeed friends with myself, a userid I will provide with, and have a column that will represent if they are and also group them if they are my friend and not my

SQL query NOT EXIST very slow

I’m trying to optimize an SQL query as it is slow, and gets slower when the query result is high. There are indexes concerned fields and Tables are quite big. Answer As a starter, this condition: Should be rewritten as: This is functionally equivalent, and not using date functions on the column being fi…

Correct way to get data for BIRT reporting

We have a system which contains 4 Hierarchies. 1. Senior Manager 2. Manager 3. Supervisor 4. Employee Data related to all these are stored in different tables with respective details. There is a single address table which contains address of all these hierarchies. Sample Data Set We would be able to do a coun…