question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'subquery must return only one column' error

See original GitHub issue

I have a simple users table, and a friends table with foreign keys user_id_1 and user_id_2.

In a seed, I add some users. In another seed I want to add some friend relationships by doing that.

knex('friends').insert({
  user_id_1: knex('users').select('id').where({username: 'bla'}),
  user_id_2: knex('users').select('id').where({username: 'blu'}),
})

This gives me back an error that subquery must return only one column. I select just the id column, so what is the problem here?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
elhigucommented, Jun 22, 2017

@coockoo looks like you are right https://runkit.com/embed/htzh2gkncj8n I was running 0.12.6 which still generated invalid output.

0reactions
pviniscommented, Jul 3, 2017

it was faulty code indeed, and thats why i answered it, for future reference 😄

good to know about clearSelect. well, i dont know if it should clear by default or no. i just thought i will ask, to know, if people know the reason, or to start a conversation, if people dont know the reason. i guess it makes send to have it explicitly like it is now.

thank you for your answer 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

error : subquery must return only one column - Stack Overflow
@user2431581, You are defining field MyField via a sub query. When you do that the sub query must only return one value and...
Read more >
ERROR: subquery must return only one column
All elements of an array must have the same type; when constructing an array with a subquery, the simplest way to enforce this...
Read more >
No way to debug "subquery must return only one column" error
The main reason is that this error occurs when an expression subquery returns more than one row when it is not expected. In...
Read more >
PostgreSQL error: subquery must return only one column ...
Coding example for the question PostgreSQL error: subquery must return only one column-postgresql.
Read more >
#28664 (basic subquery generates invalid sql) – Django
The subquery is selecting all columns, causing django.db.utils.ProgrammingError: subquery must return only one column. Oldest first. Newest first. Threaded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found