PDA

View Full Version : php mysql SELECT



owelowe
November 2nd, 2007, 04:09 PM
I have a problem with extracting information from a mysql database, I want to search the database using a number like to, but in the database the rows can have several numbers like for example:

name jord
first 234




SELECT * FROM database WHERE jord =2";


can I search the rows for individual numbers eventhou there are more than one number in the row?

Utech22
November 2nd, 2007, 08:04 PM
SELECT * FROM database WHERE jord LIKE "%2";

Read through this: http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

kaykays
November 2nd, 2007, 09:49 PM
jord = 2 will select only value 2

jord LIKE "%2" will select any number with 2 as last digit

jord LIKE "%2%" will select any number with 2 at any position


SELECT * FROM database WHERE jord LIKE "%2%";

owelowe
November 3rd, 2007, 12:07 PM
Worked thanks alot!!!