Category "subquery"

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

MySQL correlated subquery very slow when range is included

DB Fiddle: https://www.db-fiddle.com/f/u1N4YYV3wmiWndnZNb95xz/5 For the following tables nodes and leaves, with nodes having just 9 records and leaves having a

Error: 'duplicate key value violates unique constraint' even when checking with 'where not in'

I get the error: 'duplicate key value violates unique constraint' even when checking if the primary key is already in the table in which I want to insert. I ha

SQL group by in Subquery

I'm trying to get monthly production using group by after converting the unix column into regular timestamp. Can you please tell how to use group by here in the

Subquery in yii2

I have 2 tables projects (id,name) accounts (id,project_id,account_name) I want to find all projects with their account_name like this SELECT Project.*,(S

WordPress Subquery returns more than 1 row on SELECT

I am executing this query with core cron by custom Wordpress plugin: // MAKE SQL CALL $SQL = "SELECT ".$wpdb->prefix."postmeta.post_id FROM ".$wpdb->

Subquery in yii2

I have 2 tables projects (id,name) accounts (id,project_id,account_name) I want to find all projects with their account_name like this SELECT Project.*,(S

Using SELECT TOP 1 in subquery in outer SELECT list (SAP ASE 16)

I have a query that works in Sybase SQL Anywhere 11 that I need to compile in SAP Adaptive Server Enterprise 16. The code doesn't want to compile in ASE though,

MySQL subquery overview

Alright I am guessing I need a subquery to solve this and I am little rusty on these. So I have 3 tables: tblAccount - Has User information and AccountID tblIte

ORA 01797- operator must be followed by any or all

I am testing a condition like this in the where clause of a subquery. But I am getting the error "operator must be followed by any or all" when I execute the SS