Jump to content

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.

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.