Reputation: 9293
Content of entire pos
column is home01+home03
or home02+home04
.
I need to select rows where pos
contains home01
.
$pos = 'home01';
$stmt = $db->query("select * from banners where pos contains '" . $pos . "'");
Nothing is selected.
Also I need to avoid LIKE
statement because of large table.
Any help?
Upvotes: 2
Views: 265
Reputation: 2007
You can use match againts
ALTER TABLE table_name ADD FULLTEXT(pos);
SELECT * FROM banners MATCH(pos) AGAINST('+$pos+');
Upvotes: 2
Reputation: 5690
use this query
select * from banners where pos like'%" . $pos . "'";
this query return all row where first match home01
Upvotes: 0