I'd like to ask how to concatenate strings in SQL (Delphi XE2)
I'd like to ask how to concatenate strings in SQL (Delphi XE2)
for example a field X from table A is composed from two sub-field Y and Z from table B. I tried :
select * from A where X= (select Y||Z from B) it didn't work like this, neither with CONCAT( Y, Z) or COCATENATE.
X= ABCD , Y= AB, Z= CD for example
any help from experts!!
Thanks in advance.
for example a field X from table A is composed from two sub-field Y and Z from table B. I tried :
select * from A where X= (select Y||Z from B) it didn't work like this, neither with CONCAT( Y, Z) or COCATENATE.
X= ABCD , Y= AB, Z= CD for example
any help from experts!!
Thanks in advance.
This seems more like a SQL query question than something specific to Delphi. You haven't said which RDBMS product are using (SQL Server, MySQL, PGSQL, etc.), nor have you expanded upon, "it didn't work". Are you getting an error message or just not the results you expect?
ReplyDeleteOnce you provide these details, you may find more people able to provide useful assistance.
Try Y + Z. Also, if your subquery returns more than one result you'll likely get an error.
ReplyDeleteit's an ADOQuery connected to DBase file (DBF).
ReplyDeleteInstead of || try the + (plus sign)
ReplyDeleteThank you! IT WORKS.
ReplyDeleteIt may be the answer
ReplyDeletemysql> select X from A, B where A.X = CONCAT(B.Y, B.Z);
+--------+
| X |
+--------+
| javascript |
+--------+
1 row in set (0.00 sec)