Jump to content

Quick syntax question


emma57573

Recommended Posts

Ive forgotton how to do this and cant find the syntax

 

Im searching in a mysql table and I want to say if the field is blank!

 

If you get hat I mean so:

$mytable=mysql_fetch_array(mysql_query("select * from mysqltable where !field="""));

 

but you cant do '!' in the middle of a query for !field="" so what can you do to ask if the field is blank?

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/130415-quick-syntax-question/
Share on other sites

test

<?php
//test #1
$query = "SELECT * FROM mysqltable WHERE NOT ISNULL(field)";
//test #2
#$query = 'SELECT * FROM mysqltable WHERE field !="" ';

$result = mysql_query($query) or die("error in: '$query'<br>".mysql_error());
$myrow=mysql_fetch_array($result);
echo "<pre>";
print_r($myrow);
?>

Im searching in a mysql table and I want to say if the field is blank!

 

What do you mean, "say if the field is blank!"?  Looks to me you want to get all records that aren't blank...

 

If that's the case then you should use MadTechie's solution and use the NOT ISNULL(). 

Still nothing Ive been playing with 'IS NOT EMPTY STRING' but with no luck

:(

 

Your question is unclear. First you say you want to select a record where the field IS empty, now your saying where its NOT empty. Which is it?

 

IIRC, SQL syntax uses the NOT keyword instead of the ! operator.

 

The ! operator is perfectly valid, at least in MySql.

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.