Jump to content


Photo

Select statement question


  • Please log in to reply
3 replies to this topic

#1 Dawie

Dawie
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationCape Town, South Africa

Posted 03 November 2003 - 12:18 PM

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

#2 theverychap

theverychap
  • Staff Alumni
  • Advanced Member
  • 78 posts
  • LocationDevon, England

Posted 03 November 2003 - 04:51 PM

try using LIKE:


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


#3 Dawie

Dawie
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationCape Town, South Africa

Posted 04 November 2003 - 07:33 AM

Thanks very much!!. Problem solved!.

#4 theverychap

theverychap
  • Staff Alumni
  • Advanced Member
  • 78 posts
  • LocationDevon, England

Posted 04 November 2003 - 09:20 AM

glad to hear it!

no worries... :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users