Nested SELECT is used when some select query is used under a select query like SELECT * FROM (SELECT * FROM TABLE)
Questions tagged [nested-select]
46 questions
0
votes
1 answer
MySQL Nested Select with Joined Table
I'm assuming there's a way to do this with MySQL but my experience with relational databases is limited so I'm hoping to get some guidaince.
I have a users, registrations and user_registrations table. I'm want to create a SELECT query on my users…

Ross
- 112
- 1
- 17
0
votes
1 answer
How Can I Create two new fields in a list by filtering the one specific field in MVC?
I have a ViewModel as:
public class ApplicationContentViewModel
{
public BPMSPARS.Models.MySql.application application {get; set;}
public BPMSPARS.Models.MySql.content content { get; set; }
public BPMSPARS.Models.MySql.app_delegation…

Lili.brh
- 25
- 1
- 7
0
votes
2 answers
Grouping results from multiple tables
I have 6 tables: 3 for general data about anime/manga/ova/whatever and 3 for their genres which is a 1-to-m relationship
anime: manga: ova:
aid | data | ... | mid | data | ... | oid | data | ...…

chosen
- 23
- 5
0
votes
2 answers
Selecting subset of columns in table based on their names using SQL
I have a table in Postgres DB which has a lot of columns such as "id, name, a01, a02, a03, ..., a20, b, c, d, e, f". I want to check whether any of these 'aXX' columns has value 'Y'.
I know the trivial way which is:
SELECT name FROM table T
WHERE…

user1155981
- 33
- 1
- 5
0
votes
3 answers
mySQL - SELECT using JOIN, or a nested SELECT (sub-select)?
I am trying to write a SELECT in mySQL (and PHP) that will retrieve all the rows in "Images" table that were not ranked yet by a certain user.
Those are my tables:
Table: Images
+-----------+----------+-----------+----------+
| Index |…

marble
- 51
- 7
0
votes
3 answers
How to change query to nested select?
I have a project where I have to use nested select and operators like EXISTS, IN, ALL, ANY, to find the name of the owners who own more apartments.
I have the 2 tables owners and apartments
Owner
"ID" NUMBER(5,0),
"NAME" VARCHAR2(20),
"PHONE"…

OanaV.
- 81
- 2
- 7
0
votes
1 answer
SQL - charges and payments in same column; how to break it out
I have a SQL query that is pulling data from multiple tables (I have 11 joins)
There is an "ARTransaction" table which contains charges, payments, adjustments, etc. and there is a "transactionCodeID" column inside of that which describes the type of…

Taylor Weaver
- 3
- 1
0
votes
1 answer
Laravel eloquent relation for nested select query of mysql
I am stuck in the middle of nowhere in Laravel Eloquent relation for nested select query of MySQL. My query goes this way.
SELECT
*,
GROUP_CONCAT(p.facility) AS facility
FROM
(SELECT
`proposals`.*,
`proposals`.`desc` AS `pending`,
…

kushalbhaktajoshi
- 4,640
- 3
- 22
- 37
-1
votes
2 answers
Conditional Postgres Query
The PG table looks like this:
id - name - type
1 - Name 1 - Type A
2 - Name 1 - Type B
3 - Name 2 - Type A
4 - Name 2 - Type B
5 - Name 3 - Type A
I would like to write a query that only lists rows in which Name has a 'Type A' record but not…

Brodie
- 3,526
- 8
- 42
- 61
-1
votes
3 answers
Are scalar subqueries in a group by a bad practice?
I have this query. Should the nested select be avoided ? Is there a better way ?
WITH cte(oi, oIdOf) AS (
SELECT ROW_NUMBER() OVER (ORDER BY resIdOf), resIdOf
FROM @res
WHERE resIdOf<>0
GROUP BY resIdOf
)
INSERT INTO @fop
SELECT…

Ludovic Aubert
- 9,534
- 4
- 16
- 28
-1
votes
1 answer
Return latest price per product - SQL
I am an SQL Noob and have been thrown in at the deep end it feels, I have been asked to pull some data from a DB using an existing script. I need to modify the script such that I pull the product info using the latest price for each product. Having…

TheGoat
- 2,587
- 3
- 25
- 58
-1
votes
1 answer
Convert complex nested selects in Entity Framework query
I need to create a table in View by this View Model:
public class ApplicationContentViewModel
{
public BPMSPARS.Models.MySql.application application {get; set;}
public BPMSPARS.Models.MySql.content content { get; set; }
public…

Lili.brh
- 25
- 1
- 7
-1
votes
2 answers
Nested select statement in mysql -my code doesn't work
here is my query
SELECT con_serial,column2,column3
FROM
(SELECT con_serial,column2,column3
FROM big_table
WHERE ISNULL(contact1, '')+'#'+ISNULL(contact2, '')+'#'+ISNULL(contact3, '')+'#'+ISNULL(contact4, '')+'#'+ISNULL(contact5, '')
LIKE '%' +…

khoshrang
- 146
- 11
-1
votes
6 answers
Mysql get SUM and COUNT value from two tables
This is my tables
table 1: orders
id total order_date
1 200 2016-04-22
2 300 2016-04-22
table 2: order_products
id order product_id qty
1 1 1 2
2 1 2 1
3 2 2 2
4 2 1 …

MGM
- 223
- 1
- 13
-2
votes
2 answers
Can I nest a select statement within an IF function in SQL?
Using Teradata..
I want to write a query that joins table 1 and table 2 on item code to the location in table 2.
There are multiple locations per item code and potentially multiple item code entries per location depending on date. I'm only…

brittykitty
- 1
- 1