Jump to content

[SOLVED] Sql query not returning any results?


28rain

Recommended Posts

There is definetly data in the table with the word jack in it.

// Connect to MySQL
mysql_connect("******", "*****", "*****") or die(mysql_error());
mysql_select_db("shop") or die(mysql_error());

$metod=$_POST['search'];

// Insert a row of information into the table "example"
$result = mysql_query ("(SELECT * FROM f_watch WHERE notes LIKE 'jack') 
UNION
(SELECT * FROM m_watch WHERE notes LIKE 'solo')
UNION 
(SELECT * FROM cufflinks WHERE notes LIKE 'jack')")

or die(mysql_error()); 

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {

When it searches for like '%' all the results are returned

Thanks

you need the wildcards around jack:

 

$result = mysql_query ("(SELECT * FROM f_watch WHERE notes LIKE '%jack%')
UNION
(SELECT * FROM m_watch WHERE notes LIKE '%solo%')
UNION
(SELECT * FROM cufflinks WHERE notes LIKE '%jack%')")

Archived

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

×
×
  • Create New...

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.