php - Search query involving two tables in mysql -
i have 2 tables, users , sales. sales.userid = user.id
trying utilize next query. search parameters in both users , sales.
select * sales inner bring together users on users.id = sales.userid 'users.fullname' '%cloud%' or 'users.storename' '%cloud%' order sales.id desc
no result showing up. wrong in query.
e.g 1 user['fullname']
cloudbuck abc
if(isset($_get["q"]) && $_get["q"]!="") { $q = trim($_get["q"]); $where = "where users.fullname '%".$q."%' or users.storename '%".$q."%'"; } $query = "select * sales inner bring together users on users.id = sales.userid ".$where." order sales.id desc";
remove single qoutes around column names:
select * sales inner bring together users on users.id = sales.userid users.fullname '%cloud%' or users.storename '%cloud%' order sales.id desc
because mysql utilize string if single quote set.
php mysql
No comments:
Post a Comment