Dawie Posted November 3, 2003 Share Posted November 3, 2003 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 Link to comment https://forums.phpfreaks.com/topic/1279-select-statement-question/ Share on other sites More sharing options...
theverychap Posted November 3, 2003 Share Posted November 3, 2003 try using LIKE: SELECT * FROM table WHERE surname LIKE \'$surname%\'" or SELECT * FROM table WHERE surname LIKE \'%$surname%\'" Link to comment https://forums.phpfreaks.com/topic/1279-select-statement-question/#findComment-4265 Share on other sites More sharing options...
Dawie Posted November 4, 2003 Author Share Posted November 4, 2003 Thanks very much!!. Problem solved!. Link to comment https://forums.phpfreaks.com/topic/1279-select-statement-question/#findComment-4277 Share on other sites More sharing options...
theverychap Posted November 4, 2003 Share Posted November 4, 2003 glad to hear it! no worries... Link to comment https://forums.phpfreaks.com/topic/1279-select-statement-question/#findComment-4279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.