Jump to content

Archived

This topic is now archived and is closed to further replies.

Dawie

Select statement question

Recommended Posts

Hi,

I have a simple table:

id surname

1 gastrow

2 gilmer

3 green

4 greenwood

5 gunther

(sorted in surname)

When the user types in \"gr\" and clicks \"go\" the select statement should return \"green\" and \"greenwood\" I\'m using:

\"SELECT * FROM table WHERE surname >= \'$surname\'\"

but this also returns \"gunther\" which is incorrect.

Anybody with advice please?

Thanks

Share this post


Link to post
Share on other sites

try using LIKE:

 

 


SELECT * FROM table WHERE surname LIKE  \'$surname%\'"

or


SELECT * FROM table WHERE surname LIKE  \'%$surname%\'"

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.