Skip to content

Instantly share code, notes, and snippets.

@lotsofcode
Created April 3, 2012 20:26
Show Gist options
  • Save lotsofcode/2295273 to your computer and use it in GitHub Desktop.
Save lotsofcode/2295273 to your computer and use it in GitHub Desktop.
mysql commands
SELECT CONCAT('Mr. ', forename, ' ', surname, ' - ', jobTitle) FROM table;
CREATE TABLE [NEW_TABLE] LIKE [OLD_TABLE];
INSERT INTO [NEW_TABLE] SELECT * FROM [OLD_TABLE];
CREATE TABLE products_backup LIKE products;
INSERT INTO products_backup SELECT * FROM products;
; This will create the table and maintain any indexes / keys etc and it's by far the most efficient way I have found.
INSERT INTO table (forename, dayphone, address1, address2, address3, postcode, country, email)
select r.first_name r.phone_number, r.address1, r.address2, r.address3, r.post_code, r.country, r.email from table2 r;
SELECT
id, `name`, title,
CASE id
WHEN 2 THEN 1
WHEN 3 THEN 1
ELSE 0
END AS selectedCase
FROM tabl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment