mysql-error-1242

Mysql::Error: Subquery returns more than 1 row:

喜夏-厌秋 提交于 2020-01-06 06:18:11
问题 In my rails app, I am running a sql query using find_by_sql() since I need subqueries. This works if I do either the first or second query but when I add them together with the AND, it starts complaining about more than 1 row in subquery. I want all rows (records) returned that match the criteria. What needs to be fixed/changes here? What is telling mysql I only want 1 row? Here is the resultant SQL as viewed in the rails log: Mysql::Error: Subquery returns more than 1 row: select p.* from

help with subquery! returns more than 1 row

99封情书 提交于 2019-12-31 06:53:28
问题 i dont understand the problem with returning multiple rows: here is my table BBC: name region area population gdp Afghanistan South Asia 652225 26000000 Albania Europe 28728 3200000 6656000000 Algeria Middle East 2400000 32900000 75012000000 Andorra Europe 468 64000 Angola Africa 1250000 14500000 14935000000 etc............................. question: List the name and region of countries in the regions containing 'India', 'Iran'. this is my statement: select name from bbc where region =

Why does MySql give “Subquery returns more than 1 row” error?

风流意气都作罢 提交于 2019-12-25 03:56:43
问题 Hi guy i am selecting my active record from my table estates and all my other record are fine but the active record give me errors my code is @query = Estate.find_by_sql"SELECT (e.name) as estate_name, g.name as governing_body,"+ "(select count( ) from stands s where s.estate_id = e.id AND #{filter_estates}) as total_stands, "+ "(select e.active from estates e where e.active = true AND #{filter_estates}) as estate_status, "+ "(select count( ) from services sp where sp.estate_id = e.id AND #

#1242 - Subquery returns more than 1 row - mysql

与世无争的帅哥 提交于 2019-12-18 12:37:38
问题 I am trying to make a select statement that selects the image names from a MySQL database. The table is called - pictures_archive. I am also trying to select these pictures depending on the category they have. The code is: SELECT pictures_archive_filename FROM pictures_archive WHERE pictures_archive_id = (SELECT pictures_archive_id FROM pictures_archive_category WHERE pictures_category_id = 9) It gives me an "#1242 - Subquery returns more than 1 row" error. I can see why, but can't figure it

mysql error: sub-query returns more than 1 row

半腔热情 提交于 2019-12-13 20:45:17
问题 I am using two tables here projections_report p and access_rights a . I can't find out why I am getting the error: subquery returns more than one row (case when paramChannel='AllC' then p.gl_sal_chan in (case when dc_lob=0 then (select distinct pr.gl_sal_chan from projections_report pr) else (select distinct pr1.gl_sal_chan from projections_report pr1 where pr1.gl_sal_chan in (select distinct a.gl_sal_chan from access_rights a where a.userid= paramUserId)) end) else p.gl_sal_chan =

How to resolve this in Mysql (#1242 - Subquery returns more than 1 row )?

别说谁变了你拦得住时间么 提交于 2019-12-08 13:17:02
问题 I have posted 3 queries here. Actually I want to join 1st & 2nd query. As I want to have result of sc.message along with my 2nd query resultset. Just check my third query which gives above #1242 error? Plz guide me... Query1=(SELECT sc.message FROM sales_flat_order sfo, `sales_flat_order_item` `sfoi` LEFT JOIN `shipping_comment` `sc` ON `sfoi`.`shipping_comment_id` = `sc`.`shipping_comment_id` WHERE sfoi.order_id = sfo.entity_id AND sfo.increment_id = 100000429) Query2= (SELECT sfoi.name,

mysql query room availability

不问归期 提交于 2019-12-04 05:56:54
问题 Having looked at some of the other mysql availability query questions on here has got me so far, but the way mine works is slightly different to the others. Basically I have a table of dates, and each date is a row. Each row contains fields to say the cost, room type, and how many days your booking has to be to book on that date. So if a Hotel has 1 room type, it will have 365 rows, if it has 5 room types, it will have 1825 rows bd_id int(10) NO PRI NULL auto_increment bd_room_type varchar(32

Using GROUP_CONCAT on subquery in MySQL

ぃ、小莉子 提交于 2019-12-03 06:29:01
问题 I have a MySQL query in which I want to include a list of ID's from another table. On the website, people are able to add certain items, and people can then add those items to their favourites. I basically want to get the list of ID's of people who have favourited that item (this is a bit simplified, but this is what it boils down to). Basically, I do something like this: SELECT *, GROUP_CONCAT((SELECT userid FROM favourites WHERE itemid = items.id) SEPARATOR ',') AS idlist FROM items WHERE

Using GROUP_CONCAT on subquery in MySQL

☆樱花仙子☆ 提交于 2019-12-02 20:04:15
I have a MySQL query in which I want to include a list of ID's from another table. On the website, people are able to add certain items, and people can then add those items to their favourites. I basically want to get the list of ID's of people who have favourited that item (this is a bit simplified, but this is what it boils down to). Basically, I do something like this: SELECT *, GROUP_CONCAT((SELECT userid FROM favourites WHERE itemid = items.id) SEPARATOR ',') AS idlist FROM items WHERE id = $someid This way, I would be able to show who favourited some item, by splitting the idlist later

Subquery returns more than 1 row in mysql

时间秒杀一切 提交于 2019-12-02 14:34:22
问题 I am executing the following query and got the error "Subquery returns more than 1 row" My Query is SELECT pkTicketID, TicketReplyDateAdded, TIMESTAMPDIFF(DAY, TicketReplyDateAdded, now()) as NumberOfDays FROM tickets as T LEFT JOIN ticket_replies as TR ON T.fkTicketReplyID=TR.pkTicketReplyID WHERE 1 AND T.fkEmployeeID = '4' AND (SELECT TIMESTAMPDIFF(DAY, TicketReplyDateAdded, now()) as NumberOfDays FROM tickets as T LEFT JOIN ticket_replies as TR ON T.fkTicketReplyID=TR.pkTicketReplyID ) = 7