Note that there are some explanatory texts on larger screens.

plurals
  1. POnode.js and mysql
    primarykey
    data
    text
    <pre><code>result = db.query("SELECT user_id "+ "FROM friends "+ "WHERE user_id IN "+ "(SELECT to_id FROM friends WHERE user_id = " + client.user_id + ") "+ "AND to_id = " + client.user_id); </code></pre> <p><code>client.user_id</code> is 1. checked and confirmed.</p> <p>This statement has some issues with it. I have a console.log("a") after this line and it wont execute, but if i put a console.log("b"), it is executed.</p> <p>just running the resulting sql query ie</p> <pre><code>SELECT user_id FROM friends WHERE user_id IN (SELECT to_id FROM friends WHERE user_id = 1) AND to_id = 1 </code></pre> <p>returns one row with <code>user_id</code> = 2</p> <p>a separate node.js program with the query</p> <pre><code>SELECT user_id FROM friends WHERE user_id IN (SELECT to_id FROM friends WHERE user_id = 1) AND to_id = 1 </code></pre> <p>works just fine. which leads me to believe that it probably has to do smthng with client.user_id</p> <p>any ideas?</p> <p>UPDATE:</p> <p>A test with client = {user_id: 1}</p> <p>and the original query in a separate program is working...</p> <p>Edit: the fundtion where this query is being used.</p> <pre><code>function subscribe_to_friends(client) { result = db.query("select user_id from friends where user_id IN (select to_id from friends where user_id = " + client.user_id + ") and to_id = " + client.user_id); } </code></pre> <p>and the function calling this</p> <pre><code>client.on('message', function(msg) { if(client.user_id == null) { client.user_id = msg.user_id subscribe_to_friends(client); clients.push(client); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload