Jump to content

Using LIKE in mysql_query


Driimer

Recommended Posts

$query = mysql_query("SELECT * FROM wt_gremd WHERE redwid LIKE '%0%'") or die(mysql_error());
if(mysql_num_rows($query))

 

Would need this to get only one value from redwid row at wt_gremd table where blawty_ID is 1.

 

I mean wt_gremd table looks like this:

 

Table_ID # blawty_ID # redwid

4_______#___23____#___97__

5_______#___44____#___100_

 

So if BLAWTY_ID = 44 it will give value 100 from REDWID column. Point is if value equals 0 then it stops and exits script.

 

Current script will look all rows and if redwid = 0 in any of them then it stops script.

However would need it to kill script only if blawty ID = 44 in that script.

 

Link to comment
https://forums.phpfreaks.com/topic/177209-using-like-in-mysql_query/
Share on other sites

Your post makes absolutely no sense whatsoever.

Here, I made it clear with two pictures:

 

tabledh.jpg

In this case script gets killed because it will get row where blawty_ID is 50 and then goes to check that rows redwid value which is 0.

 

table2.jpg

In this case it would do the same however since redwid value is 1 then script wont get killed.

 

----

 

I want to specify blawty_ID value and it would find that row thanks to that. Then checks from that row if redwid value is 0. If it is 0 then it kills script. Else script keeps on running.

 

Current script check for value 0 from every row inside colum redwid. That means it would kill script in row where blawty_ID 38 is 0 aswell but I dont want that to happen because specified blawty ID is 50.

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.