Skip to content

Tag: mysql

Why use GTIDs in MySQL replication?

When it comes to database replication, what is the use of global transaction identifiers? Why do we need it to prevent concurrency across the servers? How is that prevention achieved exactly? I tried to read the documentation at http://dev.mysql.com/doc/refman/5.7/en/replication-gtids.html but still could not…

SELECT *, SUM(NET) AS TOTAL FROM TABLE1 WHERE CLAUSE

I was hoping to add an IF statement before WHILE. Which will still display records even there is no match dv_id on both table2. It should still display records.. The COLUMN ROLLS IF No match it will display a 0.00 value. LINK>> http://i599.photobucket.com/albums/tt79/emcevo/viewphpdisplay_zpsfc6a8174.jp…

INSERT or UPDATE from another table in mysql

I have two tables, with same schema – create table test1 ( a INT NOT NULL , b INT NOT NULL , c INT, PRIMARY KEY (a,b) ); create table test2 ( a INT NOT NULL , b INT NOT NULL , c INT, PRIMARY KEY (a,…

MYSQL show all rows where no duplicates found

If I had a set of data like this: What would be the SQL query to display only “James Peters”. So I am not wanting to remove duplicates (DISTINCT command) but rather show all rows where there are no duplicates found. Answer You would use group by for this with a having clause:

MySQL SubString Returns Integer

I’ve got a table with a varchar(128) field called identifier. It is supposed to get a 3 letter identifier followed by an indexing number: At some point in the past, there was a bug and about 5,000 records were input as: Our numbers do not go that high, so these values are padded with zeros (0). I wrote …

Mysql issue with WHERE in clause

What is wrong with my “where in” clause in mysql? My two tables SEATS and REGISTERS look like this The query to fetch the matching results is Can someone figure out what’s wrong ? Thanks, Answer IN requires the list to be a literal list, not a comma-delimited string. Use FIND_IN_SET for that…