P. 1
MYSQL & PHP Referance

MYSQL & PHP Referance

|Views: 12|Likes:
Published by jwzumwalt
A simple guide and reference for using MySql with PHP. Includes many simple examples. Most topics include a short 5 to 10 line program that demonstrates a concept.
A simple guide and reference for using MySql with PHP. Includes many simple examples. Most topics include a short 5 to 10 line program that demonstrates a concept.

More info:

Published by: jwzumwalt on Feb 07, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/21/2015

pdf

text

original

DELETE row.

DELETE from t1 where c1 = 'whatever';

UPDATE row.

UPDATE t1 SET c1=value, c2=value2,... WHERE c3=value

SHOW selected rows with the value "whatever".

SELECT * FROM t1 WHERE c1 = "whatever";

SHOW rows containing the name "Bob" AND the ph number '123-4567'.

SELECT * FROM t1 WHERE c1 = "Bob" AND c2 = '123-4567';

SHOW rows not containing "Bob" AND the ph number '123-4567', order ph_number.

SELECT * FROM t1 WHERE c1 != "Bob" AND c2 = '123-4567' order by c2;

SHOW all rows starting with the letters 'bob' AND the ph number '123-4567'.

SELECT * FROM t1 WHERE c1 LIKE "Bob%" AND c2 = '123-4567';

SHOW all rows starting with the letters 'bob' AND the ph number '123-4567' LIMIT to rows 1 through 5.

SELECT * FROM t1 WHERE c1 LIKE "Bob%" AND c2 = '123-4567' LIMIT 1,5;

Use regex to find rows.
Use "REGEXP BINARY" to force case-sensitivity.
This finds any record beginning with “a”.

SELECT * FROM t1 WHERE REC RLIKE "^a";
SELECT * FROM t1 WHERE REC RLIKE "text%";

SHOW UNIQUE rows.

SELECT DISTINCT c1 FROM t1;

SHOW rows sorted in an ascending (asc) or descending (desc).

SELECT c1, c2 FROM t1 ORDER BY c2 DESC;

INSERT one or more rows from one table to another table.

INSERT INTO t1(c1, c2) SELECT (b1, b2) from t2 where 1;

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->