select with left join and null values

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

select with left join and null values

Post by pelegk2 »

when i make a select using LEFT JOIN
i recive on some rows null - which is ok!
can i instead of the null write a string of my own?
that in case of a null value write for example "zzz"?
thnaks in adane
peleg
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

check for NULL where you output the data and replace it with the string of youe choice.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

how can i do this

Post by pelegk2 »

as part of the sql syntax
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

no as part of you php synatx when creating the hmtl
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

yes you can

Post by pelegk2 »

new things i have learned

Code: Select all

SELECT distinct P_makat_RAW,prod_name,if (tblweightstations.set_no is null,'99',tblweightstations.set_no) as station_num FROM uniprod.tblweighing..............
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

I assume you use MySQL so this will not help you. This is only (as far as I know) for Postgres users and I am writing it here for any others reading this who may be using that database system. Postgres has a command called coalesce, the description of which may be found here. http://www.postgresql.org/docs/7.4/inte ... ional.html
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

ok

Post by pelegk2 »

good to know anyway
Post Reply