Suppose there is such a query:

SELECT `street`, `house`, `apartment` FROM `table` 

Can I somehow put all 3 values ​​in 1 address variable?

  • 2
    SQL what? Maybe you need to glue them? then the concat function will come to the rescue (which truth is not the same everywhere, in some DBMS you should use their means of string concatenation, for example the operator || ) - Mike
  • one
    have you tried that? $ result = mysql_query ('SELECT street , house , apartment FROM table '); while ($ address = mysql_fetch_array ($ query)) {echo $ address ['street'];} and so on? - tCode

1 answer 1

Try string concatenation:

  1. Oracle:

     select street || ' ' || house || ' ' || apartment as address from table 
  2. MySQL:

     select concat(street, ' ', house, ' ', apartment) as address from table 

    or

     select concat_ws(' ', street, house, apartment) as address from table