0

I have this query

GetRecords = conn.RetriveQuery("SELECT * FROM tbl_student WHERE StudentID = " & studetId)

which will output a table with the following columns:

Student ID | Lastname | Firstname | Middlename | Gender | DOB | address | Contact | Email

Is there a way to create a short query which concatenates lastname,firtsname,middlename as a fullname, so that the output would be

Student ID | Fullname | Gender | DOB | Address | Contact | Email
CubeJockey
  • 2,209
  • 8
  • 24
  • 31
Al Omar
  • 21
  • 1
  • 4
  • Possible duplicate of [How to concatenate more than 2 fields with SQL?](http://stackoverflow.com/questions/3182555/how-to-concatenate-more-than-2-fields-with-sql) – The_Black_Smurf Feb 23 '16 at 19:15
  • In general, you should not use `SELECT *` in real code. The database is free to return the columns in any order if you do that. It will *almost* always return them as you expect - not *always*. You should explicitly state the columns which you want to retrieve. – Andrew Morton Feb 23 '16 at 19:23

2 Answers2

1

You can use the CONCAT function in Mysql.


SELECT CONCAT(`Firstname`, ' ', `Lastname`) FROM `table`

At least something to the effect above. That should get you the desired result. Although, I would suggest to do the concat in your VB code instead of mysql

Rishav Rastogi
  • 15,484
  • 3
  • 42
  • 47
0

Try this :

Select FirstName + ' ' + MiddleName + ' ' Surname as [Full Name] 
 from tbl_Students 
 WHERE StudentID = ?
John Slegers
  • 45,213
  • 22
  • 199
  • 169
Lickrob
  • 61
  • 2
  • 11