mysql - How to get SQL combined field result -


i have table "student" in database;

create table student  ( stud_id varchar(20), fname varchar(100), lname varchar(100), primary key (stud_id) ); 

i have data in "student" table

insert student (stud_id, fname, lname) values ('s0001', 'foo', 'bar'); 

i want find stud_id of student has full name "foo bar" how this? tried this

select stud_id student 'fname'+' '+'lname' 'fo%'; 

its not error cant "foo bar" stud_id. how this?

single quotes make column string avoid using in columns. instead of + use concat function concatenate columns

select stud_id  student  concat(fname,' ',lname) 'fo%'; 

Comments