hey guys. i have this table that lists contacts that are stored in database. the data is selected from 2 tables using join which i have already got working:

SELECT 
c.contact_id,c.salutation,c.fname,c.lname,c.dob,c.houseadd,c.personalno,c.officeno,c.email,c.spouse,c.child,
s.spouse_id,s.s_salutation,s.s_fname,s.s_lname,s.my_spouse
FROM contact1 c
LEFT JOIN spouse1 s
ON c.contact_id = s.my_spouse

what im having trouble with is selecting another column based on data in one column. okay so this is my contact1 table:

id|salutation|othersalutation|fname|lname|dob|houseadd|personalno|officeno|email|spouse|child|

column 'othersalutation' i just added it in today as requested by my supervisor. 'salutation' is only for one salutation like 'Mr.' or 'Mrs.' etc(its a dropdown in the html form) while 'othersalutation' allows user to insert multiple salutations as they want(textbox in html form)(coz just having one isn't enough) like 'Dato Sri Haji'; Dato Sri and Haji being 2 salutations.

so what i want to do is modify the above query like a conditional select like

select othersalutation if salutation = 'Other' else select salutation

something like that. there are alot of these kinda questions on the internet but coz mine is using a join as well to display data im not so sure how to put that into the query.

TIA!

um. nvm. i think i was over thinking things. found a different way to achieve what i want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.