0

I have a mySQL database that I am trying to get data from.

Here is my query:

"SELECT booking_number, customer_name, passenger_name, 
contact_phone, CONCAT(unit_number,'/', street_number, ' ', street_name, ', ', suburb) AS pickup_address, destination_suburb, pickup_datetime FROM $sql_table

If unit number is null I need to remove the literal '/'.

How can I do this?

1 Answer 1

2

use it like this

CONCAT(unit_number, IF(unit_number IS NULL, '', '/'),street_number,.........
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.