Forum Moderators: coopster

Message Too Old, No Replies

How to display only entires where certain field is present

select from where field is present

         

neo_brown

2:40 pm on Sep 28, 2004 (gmt 0)

10+ Year Member



I am trying to display some data from my database. I only want to display the entires that have a certain field populated.

EG.
If I have a list of names and addresses, only some of which have phone numbers. I want to call only the entries which have phone numbers and display them.
What do I do with the where statement?

Any help appreciated.

coopster

2:55 pm on Sep 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What column type is the phone number? That will determine how to check it.
SELECT * FROM table WHERE phonenumber > 0;

neo_brown

2:58 pm on Sep 28, 2004 (gmt 0)

10+ Year Member



Thanks for the quick response.

Sorry the example I gave was not a real one (misleading I know, my bad)

The column is varchar (for url's)
The method you have suggested is the way I have been trying and it almost does the job, except it list everything but just puts the entries with a web address present at the top.

coopster

3:08 pm on Sep 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Then simply change to check for non-character data:
SELECT * FROM table WHERE url <> '';

neo_brown

3:23 pm on Sep 28, 2004 (gmt 0)

10+ Year Member



Thanks alot.

This method seems to work upto a point. Its giving me a few probs with my pagination but I think with a little playing around it should be fine.

Thanks again for the speedy assistance.