fg2210
fg2210

Reputation: 61

Error within SQL WHERE statement spaceing

I have the following SQL code:

("SELECT doctor_id FROM doctors WHERE doctor_first_name + " " + doctor_last_name =%s", [form.doctor_name.data])

But it is not performing the function. I think it is the spacing in between the two database values but have tried every possibility I can think of to get it working and no success. Thanks

Upvotes: 1

Views: 26

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

Assuming you are using sql server or mysql

if you want add a space between doctor_first_name and doctor_last_name you could use concat

("SELECT doctor_id 
 FROM doctors 
 WHERE concat(doctor_first_name, ' ', doctor_last_name) =%s", [form.doctor_name.data])

using oracle you could use ||

("SELECT doctor_id 
 FROM doctors 
 WHERE doctor_first_name|| ' ' || doctor_last_name =%s", [form.doctor_name.data])

Upvotes: 2

Related Questions