can i use wild cards in a select statment [SOLVED]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

can i use wild cards in a select statment [SOLVED]

Post by nutstretch »

I have a field in my database which holds values seperated by ,'s
for example: 3,4,4.5,5,6,7.5

I want the user to chose a value from a list and see if that value is held in the field. for example 4.5

Can i use a wild card expression. I tried this but it returned nothing

$resultID = mysql_query("SELECT * FROM tblShoestest where fitting LIKE '$width' AND SizeRange1 LIKE '*$size*'", $linkID)or die(mysql_error());

any help appreciated
Last edited by nutstretch on Tue Feb 10, 2004 4:35 am, edited 1 time in total.
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

Last edited by malcolmboston on Tue Feb 10, 2004 4:31 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

for wildcards, use percentage signs instead of asterix

Code: Select all

$resultID = mysql_query("SELECT * FROM tblShoestest where fitting LIKE '$width' AND SizeRange1 LIKE '%$size%'", $linkID)or die(mysql_error());
Mark
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

Post by nutstretch »

Many thanks Bech100
Post Reply