Tag: sql


MySQL Generate a list of numbers

This will generate a column named SeqValue that will range from 0-255 so a total of 256 values. SELECT (TWO_1.SeqValue + TWO_2.SeqValue + TWO_4.SeqValue + TWO_8.SeqValue + TWO_16.SeqValue + TWO_32.SeqValue + TWO_64.SeqValue + TWO_128.SeqValue) SeqV...

XOR two tables in MySQL

SELECT ot.id FROM old_table ot LEFT JOIN new_table nt ON ot.id=nt.id WHERE nt.id IS NULLOnly return that which they don't have in common.Another way of saying it is only return where they do not intersect. There are many Boolean operations that can be...

MySQL splitting a comma delimited string into a column of rows

If you want to split a field of your database by commas or some delimiter into a column of rows or a list using pure MySQL here is how you can do it. I pulled this from the MySQL cookbook and then modified it to not rely on the pivot table t10. Origi...

Check if a database exists in MySQL from the command line

To check if a database exists from the command line in MySQL echo the following query and pipe (|) it to the MySQL command line utility:echo SELECT COUNT(*) as num FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMATA.SCHEMA_NAME="some_database_name"; | mysq...