Welcome Guest, Not a member yet? Register   Sign In
Empty SQL result_array
#1

[eluser]keugant[/eluser]
Hello everyone,

I'm currently working on a project that allows the user to submit links and documents organized around groups. The submission process works fine, but I'm trying to get a list of all documents and links from all the groups the user is part of.

This is why I'm trying to run a MySQL query that should fetch data from two tables (for links and documents). The query should return some sort of result since the tables are not empty.
Here is what the tables look like:

============================================
interface_link
============================================
| - ID - | - LINK ID - | - NETWORK_ID - | -TIMESTAMP - |

For the other one (interface_document), it is exactly similar except for the names (<i>link</i> is replaced by <i>document</i>)

Here is what my query looks like:

Code:
SELECT * FROM `interface_link`, `interface_document` WHERE `interface_link`.`network_id` OR `interface_document`.`network_id` IN (1, 3, 8, 9, 11, 12)

The only thing I get is an empty array <i>Array()</i>, since I run the following commands:

Code:
$query = $this->db->query($sql);
$query->result_array;

Please excuse me if the answer is obvious I'm quite new in the world of web development...

Thanks a lot Smile
#2

[eluser]TheFuzzy0ne[/eluser]
I reckon this should work
Code:
SELECT * FROM `interface_link`, `interface_document` WHERE `interface_link`.`network_id`  IN (1, 3, 8, 9, 11, 12) OR `interface_document`.`network_id` IN (1, 3, 8, 9, 11, 12)

There may be a better way to do it, though. I'm not sure.




Theme © iAndrew 2016 - Forum software by © MyBB