Jump to content

MySQL search query failing


Go to solution Solved by B_CooperA,

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.