Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SQL Server] Get comma separated values
#1
Hello !

I'm having trouble getting multiple values from an SQL table, the values are returned on the same line and stick together.

For example :
I want to get the User_ID of every people which name is "Mike" :

Macro Macro5
Code:
Select All      Help
Database db
ARRAY(str) sql
db.QueryArr("SELECT USER_ID FROM USER_TABLE WHERE USER_NAME LIKE '%Mike%'" sql)
out sql

In our example, there is 2 "Mike" in the database. One have ID 11 and the other have ID 12

But in the SQL string, QM returns me "1112", and i would like to have "11,12" in return.

Is it possible somehow ?

Thanks in advance Smile
#2
The sql array is OK, but it is 2-dimension, and out does not know how to display 2-dimension arrays. To display its elements use a for loop.

Code:
Select All      Help
int row
for row 0 sql.len
,out sql[0 row]
#3
It works, thanks a lot !


Forum Jump:


Users browsing this thread: 1 Guest(s)