Hi,
I have to run the following statement in MySQL. (The script is
generated from oracle).
*************
SELECT t1.c1, t2.c2, t3.c3
from t1, t2, t3
where t1.flag = 1
and (t1.cx = t2.cx(+) and t2.cy(+) = 1)
and ( (t2.cz(+) = t3.cz and not exists (select * from t3) )
or
(t1.c3 = 2)
)
;
****************
This looks a bit complex for me as I am not familiar with JOINs. It
would be great if someone can help me out.
Thanks,
Deepak 1 1691 de********@gmail.com wrote: Hi,
I have to run the following statement in MySQL. (The script is generated from oracle).
************* SELECT t1.c1, t2.c2, t3.c3 from t1, t2, t3 where t1.flag = 1 and (t1.cx = t2.cx(+) and t2.cy(+) = 1) and ( (t2.cz(+) = t3.cz and not exists (select * from t3) ) or (t1.c3 = 2) ) ;
The join syntax using "(+)" is specific to Oracle and does not match any
SQL standard. The equivalent in standard SQL is to use OUTER JOIN.
That join condition makes no sense from what I can tell. "not exists
(select * from t3)" is true only if the t3 table is empty. If that is
true, how can any row exist where t2.cz = t3.cz? Therefore that term in
the expression is guaranteed to be false, so it can be factored out,
leaving the other side of the "OR" expression.
The best I can guess for this is the following:
SELECT t1.c1, t2.c2, t3.c3
FROM t1 LEFT OUTER JOIN t2 ON (t1.cx = t2.cx AND t2.cy = 1)
JOIN t3 ON (t1.c3 = 2)
WHERE t1.flag = 1;
The condition (t1.c3 = 2) is highly unusual and likely not to be what
you intended for this query. It is more usual for a join condition to
describe a relationship between two tables.
This looks a bit complex for me as I am not familiar with JOINs. It would be great if someone can help me out.
You should pick up a book or find a tutorial on the web. JOINs are not
difficult to understand, but they are crucial to writing queries.
Programming in SQL without understanding JOINs is like programming in C
without understanding functions.
Regards,
Bill K. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ralph Freshour |
last post by:
I am having a hard time with joins - my following code displays:
..member_name .gender
instead of the actual data - I've been reading through my PHP and
MySQL manuals - the MySQL manual tells...
|
by: Mark Wilson CPU |
last post by:
A colleague has written a prototype program in PHP, using a MySQL
database.
It's a relatively simple app, with a restricted set of mysql commands
used (see below). The MySQL DB is being replaced...
|
by: Morten Gulbrandsen |
last post by:
Hello,
starting from some software database spesification,
defined in some Enhanced entity relationship diagram,
resulting in all kinds of
relationships,
1:1
1:Many
Many:1
|
by: Massimo Fiorentino |
last post by:
Hello there!
I am a bit of a newbee into the mySQL world and I have a question regarding
switching from one DB to another. I have for a couple of years used a very
simple CMS-system created by...
|
by: Cern |
last post by:
Is it somebody out there who has made a migration from an Oracle server to an MySQL server??
The scenario is as simply:
I've got a Oracle 8 server with a database with content that I want to...
|
by: chicha |
last post by:
Hey people,
I have to convert MS Access 2000 database into mysql database, the whole
thing being part of this project I'm doing for one of my faculty
classes. My professor somehow presumed I...
|
by: steve |
last post by:
Hi, I want to share my experience with you. If you have large tables,
and you are doing joins, be extra careful that the keys in the joins
have exactly the same size (and type). Don’t mix...
|
by: narendra vuradi |
last post by:
Hi I have a requirement where in i haev to convert the SQL from Oracle
to the one which will run on the SQL server.
in the Oracle Query i am doing multiple joins, between some 13 tables.
and...
|
by: --CELKO-- |
last post by:
I need to convert a bunch of DB2 triggers to Oracle. Is there any
kind of tools for this?
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |