Ask a Question related to Coldfusion Database Access, Design and Development.
-
nitai_co #1
Left/righ join dont know anymore
Hi all,
I need to get all the records from one table but only if some values from
other tables are verified. Ok, so this should be normal like:
select * from
tableA, tableB, tableC
where tableB.hostid = 1
and tableC.groupid <> 1
This should actually give me all records from tableA if hostid from tableB is
"1" and groupid from tableC is not "1".
So actually this returns me nothing, because not all records from tableA are
in tableC. So I thought to use a left join but all I have tried does not work
at all.
Any kind soul please enlighten me? Thank you.
nitai_co Guest
-
Is left-join faster then inner join?
Some people said that using left-join is generally faster than inner join, is that true? Thanks... -
left join limit 1
I have 3 tables, one main table, and two tables that reference the first table. the two reference tables may have more than one entry to the first... -
Left join isn't joining
Hello, I've got a select statement that joins two tables. -- tblPageHitCalendar contains a single column holding dates. It has every day since... -
swf files dont open in Flash Player Anymore!
Now every time I try to open a .swf file it asks me what program do i want to open it in i have installed flash again and again and it still isant... -
left join problem
if you just need something unique in the result set, 1. combination (NJIDATA.GLPMSTR.ID, NJIDATA.GLPMTRN.ID) is unique 2. you could also use... -
CF_Oracle #2
Re: Left/righ join dont know anymore
Put the code you tried with outer joints. What database do you query?
CF_Oracle Guest
-
paross1 #3
Re: Left/righ join dont know anymore
Also, you aren't relating the three tables to one another. How is table A
related to B and B to C (or A), etc.? I am surprised that you didn't get a
Cartesian join, where you return a product of the numer of rows in each table,
rather than nothing.
Phil
paross1 Guest
-
CF_Oracle #4
Re: Left/righ join dont know anymore
Paross you are right. That what I mean asking nitai_co to "put the code with
outer joints" here for our review and possible help. But it could be
interpreted as advise what to do. Since he/she wrote "I thought to use a left
join but all I have tried does not work at all" these 3 tables heve been
jointed somehow. Anyway we need to no foreign keys etc.
CF_Oracle Guest
-
nitai_co #5
Re: Left/righ join dont know anymore
Ok, sorry if I did not write it out properly. But the code I wrote is actually
what I am doing and I get ALL the record, but I need only the records from
tableA who DONT have 1 in the tableC.groupid field.
So this code:
select * from
tableA, tableB, tableC
where tableB.hostid = 1
and tableC.groupid <> 1
shows me all records. Trying:
select * from
tableA, tableB, left join tableC on tablec.groupid <> 1
where tableB.hostid = 1
It was a long day and I dont know where to look anymore and what to do :-) (we
are on Oracle 10g).
PS: I am a he
nitai_co Guest
-
paross1 #6
Re: Left/righ join dont know anymore
That is what I meant by a Cartesian join (ALL records returned, actually all
three tables times each other). What you need to add is how these tables are
related. You only have where tableB.hostid = 1 and tableC.groupid <> 1, but how
is tableB related to tableA? Something like tableA.hostid=tableB.hostid and
also something like tableB.groupid = tableC.groupid, etc. (This is only an
example, because you really didn't specify how these tables are related.)
Otherwise, you just get the product of their rows times each other (a Cartesian
join ).
Phil
paross1 Guest
-
nitai_co #7
Re: Left/righ join dont know anymore
Originally posted by: mxstu
I'll let someone else post an optimization of that query ;-) ... but at the
very least ... specify the column names instead of using "SELECT *".
Yes, I always do, this was just for posting and making the code look "better"
nitai_co Guest
-
mxstu #8
Re: Left/righ join dont know anymore
Okay, that's what I thought. It never hurts to make sure. Amazing the amount of people that actually use select * on a regular basis...
mxstu Guest
-
nitai_co #9
Re: Left/righ join dont know anymore
Really? hmhmhhm....those are the poeple who wonder why their application gets so slow when they hit a million records :-) Thank you for all suggestions.
nitai_co Guest



Reply With Quote

