Jump to content

How to say it


manalnor

Recommended Posts

Hello friends,

 

Can you help me as always.

 

let say we have database table (id,user,name,code)

 

and i'm gonna say MYSQL

 

$qry="select * from table order by id desc";

 

Now how to say

 

select from table where (user) is not empty and (code) is not  'something'

 

:shrug: i did tried this

 

$qry="select * from table where user IS NOT NULL AND code IS NOT LIKE 'something' order by id desc";

 

but didn't work so how to say it and where i could learn such mysql commands cause i know it only in php like x == y and x != y ..ect

 

thanks

Link to comment
Share on other sites

If you want to exclude an exact value then use:

AND code != 'something'

 

EDIT: Also, I'm not sure what your default value is (assume it's NULL) but you may want to check for an empty string as well.

AND user != ''

Link to comment
Share on other sites

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.