Jump to content

MySQL search query failing


budimir

Recommended Posts

Guys,

 

Can someone explain me, why this query is failing:

$upit_prikaz = "SELECT * FROM katalog_pribora_item LEFT JOIN katalog_pribora_slike ON katalog_pribora_item.id = katalog_pribora_slike.id_item WHERE (grupa_artikla = '1HP' OR grupa_artikla = '1HU') AND novi_pribor = '1' AND prikaz_katalog = '1' ";
$query_prikaz = mysql_query($upit_prikaz) or die (mysql_error());

And this one is working fine:

$upit_prikaz = "SELECT * FROM katalog_pribora_item LEFT JOIN katalog_pribora_slike ON katalog_pribora_item.id = katalog_pribora_slike.id_item WHERE grupa_artikla = '1HP' AND novi_pribor = '1' AND prikaz_katalog = '1' ";
$query_prikaz = mysql_query($upit_prikaz) or die (mysql_error());

Difference is that lower one is not having one OR statment.

Link to comment
https://forums.phpfreaks.com/topic/282813-mysql-search-query-failing/
Share on other sites

 


without, you will effectively have

 

There is no OR in the second query.  :-)

 

However, the first query will also grab records with grupa_artikla = '1HU', the second only '1HP', so my guess is there are no records that have '1HP' that meet the other requirements.

Guys,

 

I have managed to track my problem. Query is actually working as it was suposed to, but I messed up with id linking. That's why it couldn't return any data.

 

Got it all sorted out now.

 

Thank you for you're help. B_CooperA pushed me to a good track.

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.