Created
April 3, 2012 20:26
-
-
Save lotsofcode/2295273 to your computer and use it in GitHub Desktop.
mysql commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT('Mr. ', forename, ' ', surname, ' - ', jobTitle) FROM table; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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