Can't add two references to the same table in one grid

QuestionsCan't add two references to the same table in one grid
Andres B asked 5 years ago

Hello:
I have a situation where I have a main table with two references to another table.
I have a query similar to this:

SELECT client1.name AS name1, client2.name AS name2, sen_main.moredata FROM sen_client AS client1, sen_client AS client2, sen_main WHERE idclient1 = client1.idclient AND idclient2 = client2.idclient

When I call the grid, only the first column is populated. I tried different combinations, adding more columns, one with and another without alias, and the result is always the same, only the first reference is shown, the second reference is always left blank.

Can someone tell me the way I need to write my query so that it will populate both columns?

Thanks in advance.

1 Answers
Abu Ghufran answered 5 years ago

Hello,

Please make sure you set column name as alias OR field name if alias is not used.

// for col1
$col["name"] = "name1";

//for col2
$col["name"] = "name2";

Also try running your query on sql ide e.g. phpmyadmin to verify if it is returning data.
If still not resolved, please post your code. You can use pastebin.com for sharing.

Your Answer

1 + 11 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!