Questions tagged [on-clause]
34 questions
0
votes
2 answers
Null result from multiple left Join in postgresql
I have 3 tables in a database A, B and C which share the same column "name".
B has an attribute "title" and C has an attribute "age".
I am looking to write a SQL query where I will have to choose all the contents of A based on query input either…

bluestacks454
- 151
- 7
0
votes
1 answer
Why doesn't this work with an ON clause, but does with a WHERE clause?
Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in…

UtahMan1083
- 15
0
votes
1 answer
Doctrine 2 and "unknown column in "ON clause"
I am currently working in a project that is using Doctrine 2 with ZF. So far so good. However I have a problem that looks like a bug.
I have written the following code in one of my repository :
$dql = 'SELECT a, s.firstName, s.lastName FROM…

Bakura
- 1
- 2
0
votes
2 answers
SQL Left Join with WHERE clause SAS Enterprise Guide
I am trying to pair 2 tables (nicknamed PERSIP and ECIF) on their ID field, (labeled TABLE1 & TABLE2) to create a RESULTTABLE, where the ym_id (for both tables) variable is set to my timekey0 variable for a specific datetime.
I am wondering why this…

Dario
- 3
- 3
0
votes
1 answer
How can I remove subquery?
I need to remove the subquery. But I must maintain the condition. What can I do?
(SELECT * FROM customer_orders where status=3)
SELECT cus.id,cus.customer_name,cus.mobile,cus.email,
COUNT(CAST(cus_ord.customer_id AS INT)) AS Total_Order…

durlove roy
- 229
- 4
- 12
0
votes
1 answer
MySQL join two tables based on a condition
I have two tables.
users
| id | name |
| ---|-------|
| 1 | Jhon |
| 2 | David |
swipes
| id | swp_from | swp_to| first_swp| second_swp |
| ---|----------|-------|----------|------------|
| 1 | 1 | 2 | like | pending |
| 2 |…

Relaxing Music
- 452
- 4
- 13
0
votes
2 answers
Error Number: 1054 Unknown column '2021-08-23' in 'on clause'
I have join many tables in this query via LEFT JOIN and i want to apply condition on table but php is giving me following error
Error Number: 1054 Unknown column '2021-08-23' in 'on clause'
SELECT i.isn_Add_Date, s.scentre_Name,…

Laraib
- 17
- 1
- 7
0
votes
0 answers
HQL query for Collection using ON clause
Below is the HQL query which gives me the syntax error when I use join Operation with ON clause on the Collection property.
I have a Source.java file with one Collection property of the Customer bean with OneToMany mapping which is mapped by source…

imtejask
- 3
- 3
0
votes
1 answer
MYSQL adding OR clause in left join slowing up the query
I have two database tables: orders and customers.
I'm running a SQL to get all orders in June month.
If the Ship To and Bill To email are different, we are inserting two different records with both emails to customers table.
select o.order_id
…

Jenz
- 8,280
- 7
- 44
- 77
0
votes
1 answer
CI and in the join on
$this->default->join('db D', 'C.col1 = D.col1 AND D.col2 = "MAIN"', 'LEFT');
I am getting 500 error on this join in CI but when i only use
$this->default->join('db D', 'C.col1 = D.col1', 'LEFT');
query is ok.
How to do join in CI with and in the…

guradio
- 15,524
- 4
- 36
- 57
0
votes
1 answer
Teradata - Adding preceding zero and casting as varchar(50)
I have the following query:
SELECT
s.cola, s.colb, t.colc, t.cold, u.cole, u.colf, u.colg, u.colh, u.coli, u.colj, u.colk, u.coll
FROM table1 s
INNER JOIN table2 t
ON s.colb = t.colc
INNER JOIN table3 u
ON u.colm = CAST(t.cold AS…

skr
- 914
- 3
- 18
- 35
0
votes
1 answer
Oracle MERGE: only NOT MATCHED is triggered
Database: Oracle
Table:
CREATE TABLE TABLE_FOR_TESTS (
d DATE,
t NUMBER(8)
)
MERGE:
MERGE INTO TABLE_FOR_TESTS
USING DUAL
ON ((SELECT COUNT(*) FROM TABLE_FOR_TESTS) = 1)
WHEN MATCHED THEN
UPDATE SET T = T+1
WHEN NOT…

ROMANIA_engineer
- 54,432
- 29
- 203
- 199
0
votes
1 answer
Linq left joining with non trivial condition
This is fine, it produces a left join
var q =
from c in categories
join p in products
on c equals p.Category into ps
from p in ps.DefaultIfEmpty()
select new { Category = c, ProductName = p == null ? "(No products)" :…

Martin
- 2,956
- 7
- 30
- 59
0
votes
1 answer
Sqlite ON statement on calculated field failing
I'm trying the following query with no luck:
SELECT B.id AS BookId, P.id AS PdfId FROM tbl_Books AS B
INNER JOIN tbl_PDF AS P ON P.FileName = B.ShortName || '.pdf'
COLLATE NOCASE
Is in Sqlite possible to use a clause in ON statement?
Thanks

MaiOM
- 916
- 2
- 13
- 28
0
votes
2 answers
I am trying to link 4 tables together with INNER JOIN
My code looks like this
CREATE TABLE Genre (
genreID INT NOT NULL DEFAULT 0,
genreName VARCHAR(20) NULL,
PRIMARY KEY (genreID));
CREATE TABLE Artists (
ArtistID INT NOT NULL DEFAULT 0,
name VARCHAR(45) NULL,
Genre_genreID INT NOT NULL,
PRIMARY KEY…
user3487927