Jump to content

Nede help with Select WHERE


Topshed

Recommended Posts

MySQL client version: 5.1.56

PHP Version information: 3.4.4

 

I am in trouble with a query

The normal one which I use is like this, The idividual scrips are for Gallery Pages to populate the detailed notes with each image

so the vars are to fine the record

All 3 fields have approx 50% zeros

So I  enter the numbers where they exist and leave  zeros where they don't..

 

$tble = 'table3';
$a1_num = '12345'; //  5 Medium int   can be 0 to 99999
$b1_num = '2001';   //  4 Samll int      can be 0 to 9999
$c1_pregr = ' 0';       //  4 Samll int      can be 0 to 9999

$db="SELECT * FROM `$tble` WHERE `a1#` = '{$a1_num}' OR 'b1#' = '{$B1_num}'" ;
    $result = mysqli_query($connect,$db) or die(mysqli_error($connect));
if (mysqli_num_rows($result) > 0) {
	while ($row = mysqli_fetch_assoc($result)) { 
etc.........

 

Unfortunately field b1# has some duplicate numbers  only 20 or so but when one occurs it finds the first one  and of course I often want the second one.

To fix this I tried to utilize the third field c1# which should fix my problem but I cannot get it to work

None of thefollowing  variants work giving me  "Query returned 0 results. "

$db="SELECT * FROM `$tble` WHERE `b1#` = '{$b1_num}' AND 'c1#' = '{$c1_num}'" ;
$db="SELECT * FROM `$tble` WHERE `a1#` = '{$a1_num}' AND 'b1#` = '{$b1_num}'  AND  c1#' = '{$c1_num}'" ;

My preferred Varient would be to query all 3 fields

 

would be most welcomeplease

 

Roy...

Link to comment
https://forums.phpfreaks.com/topic/248323-nede-help-with-select-where/
Share on other sites

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.