A: 

If you have all the selects individually and then table.* that is probably your problem.

SELECT *
FROM
cart

LEFT OUTER JOIN dkb
   ON cart.id = dkb.id

LEFT OUTER JOIN cdkb
   on cart.id = cdkb.id

LEFT OUTER JOIN double
   on cart.id = double.id
WHERE 
cart.cookieId = GetCartId() AND cdkb.id IS NOT NULL
sadboy
The first outer join dkb I want to display ON cart.id= dkb.id WHERE dkb.id =$idcand the second outer join cdkb to display ON cart.id= dkb.id WHERE dkb.id =$id$idc comes from the url of page1.php to cart.php and $id comes from the url of page2.php to cart.php.... LEFT OUTER JOIN dkb ON cart.id= dkb.id WHERE dkb.id = $idLEFT OUTER JOIN cdkb ON cart.id = cdkb.id WHERE cdkb.id= $idcWHERE cart.cookieId = GetCartId()
jona
So I think that instead of dkb.id then $idc should be in that place like ON cart.id = $idc
jona
What the IS NOT NULL Means in this case?
jona
+1  A: 

To set up some data for this query for MySQL:

-- **********************************************************************
-- Table holding all the items in the users shopping cart, along with
-- a cookieId for thier session
-- **********************************************************************
Create table cart
   (
   cartId           integer,
   cookieId         integer,
   id               integer,
   qty              integer
   )
go

-- **********************************************************************
-- Table all the items available for sale with the price
-- **********************************************************************
Create table dkb
   (
   id               integer,
   name             varchar(20),
   price            decimal(12,2)
   )
go

-- **********************************************************************
-- Table that looks like the items table, but we have no idea why it is
-- here.
-- **********************************************************************
Create table cdkb
   (
   id               integer,
   name             varchar(20),
   price            decimal(12,2)
   )
go

-- **********************************************************************
-- Another table with a price in it .. a completely different id field
-- and a variety ... WTH is it for - No idea.
-- **********************************************************************
Create table dblv
   (
   dbl_id           integer,
   price            decimal(12,2),
   variety          varchar(20)
   )
go

insert into cart (cartid, cookieid, id, qty) values (1, 1, 1, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 2, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 3, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 4, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 5, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 6, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 7, 1);
go
insert into cart (cartid, cookieid, id, qty) values (1, 1, 8, 1);
go

insert into dkb (id, name, price) values (1,'my dkb 1', 10.00);
go
insert into dkb (id, name, price) values (2,'my dkb 2', 20.00);
go
insert into dkb (id, name, price) values (3,'my dkb 3', 30.00);
go
insert into dkb (id, name, price) values (4,'my dkb 4', 40.00);
go

insert into cdkb (id, name, price) values (5,'my cdkb 5', 50.00);
go
insert into cdkb (id, name, price) values (6,'my cdkb 6', 60.00);
go
insert into cdkb (id, name, price) values (7,'my cdkb 7', 70.00);
go
insert into cdkb (id, name, price) values (8,'my cdkb 8', 80.00);
go

insert into dblv (dbl_id, price, variety) values (1,1.99,'my dbl 1 variety');
go
insert into dblv (dbl_id, price, variety) values (2,1.99,'my dbl 2 variety');
go

then the results of this query:

SELECT
   cart.id    cart_id,
   dkb.id     dkb_id,
   cdkb.id    cdkb_id,
   cart.*,
   dkb.*,
   cdkb.*,
   dblv.*
FROM
    cart

    LEFT OUTER JOIN dkb
       ON cart.id = dkb.id

    LEFT OUTER JOIN dblv
       on dkb.id = dblv.dbl_id

    LEFT OUTER JOIN cdkb
       on cart.id = cdkb.id

results show up as:

cart_id    dkb_id     cdkb_id    cartId     cookieId   id         qty        id         name                 price        id         name                 price        dbl_id     price        variety              
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------------------- ------------ ---------- -------------------- ------------ ---------- ------------ -------------------- 
1          1          NULL       1          1          1          1          1          my dkb 1             10.00        NULL       NULL                 NULL         1          1.99         my dbl 1 variety     
2          2          NULL       1          1          2          1          2          my dkb 2             20.00        NULL       NULL                 NULL         2          1.99         my dbl 2 variety     
3          3          NULL       1          1          3          1          3          my dkb 3             30.00        NULL       NULL                 NULL         NULL       NULL         NULL                 
4          4          NULL       1          1          4          1          4          my dkb 4             40.00        NULL       NULL                 NULL         NULL       NULL         NULL                 
5          NULL       5          1          1          5          1          NULL       NULL                 NULL         5          my cdkb 5            50.00        NULL       NULL         NULL                 
6          NULL       6          1          1          6          1          NULL       NULL                 NULL         6          my cdkb 6            60.00        NULL       NULL         NULL                 
7          NULL       7          1          1          7          1          NULL       NULL                 NULL         7          my cdkb 7            70.00        NULL       NULL         NULL                 
8          NULL       8          1          1          8          1          NULL       NULL                 NULL         8          my cdkb 8            80.00        NULL       NULL         NULL                 

sorry not much time today - long day at work. :-) I'll check back tomorrow ..

Ron Savage
Before I post the tables structures I want to add that double table is join on dlb.id = dkb.id as you post it and will display its table information together with dkb table. Both of them need to be on since they are displaying information together.
jona
Look at the first post I have edited and I have post the complete query with the field names.
jona
Exactly, because you wanted it to be only displayed if cart.id = dkb.id ... so it is really JOINed to dkb.id. :-)
Ron Savage
your last comment was in reference to my last to the first comment after your answer post or the edit of the first post I did?
jona
In reference to the first comment above. :-) Anyway, appears your problem is solved!
Ron Savage
I just have to test it now, I wanted to do the final retouch theoretically speaking. Now I have to go and do the work. Thank you Ron
jona
how can you echo the query so the dynamics can be seen?I have used $result = mysql_query("SELECT.....")
jona
Ron check the first post for some edit work I have added '".$ids."' and '".$idc."' so the syntax can be fixed. But then the query is not display the information nof dkb ON dkb.id = '".$ids."' as well as cdkb.id = '".$idc."'.
jona
@Ron I have re-edited the first post again and added some php and html code in the first post and some explanation on why the cart won't display the name of the item and the price as well?Ron I have created another question just because it seems you are sleeping, not ignoring your knowledge but for speed purposes But I will appreciate you still having an opinion after you come back in the morning thanks you!
jona
Ron any ideas on the problem?
jona
Hello Ron any opinions on his take brother! i am drowning on an sql error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM cart LEFT OUTER JOIN dkb ON (cart.id = dkb.i' at line 21Don't know where is coming from everything aparently seem to be ok. but not. Give me a hand here
jona
@Ron I haven't test your new changes, But I have to say that the query cdkb table that looks like the item tables has exactly the same fields of the items tables, its like a second items table the thing is that I have done like that because of a design clash. For instance I have a table that has menu subjects names another that has the submenus subjects. let's say that the menu subjects has 5 subjects then the first menu subject and the fourth emnu subject in my case uses the same submenu subjects but with variation on design because both menu sujects first and fourth handle diferent menu ->
jona
subjects. handle same subemnu suject but diferent submenu design. But the issue is not the diferent menu subject, or having the same submenu subject or having diferent submenu design in part but no puting two different relational ids in one field. For instance I can not assign two id to the same field in order to direct the database to recognize that first submenu subject is for this menu subject and the other relational foreign key for the second submenu suject. In order for me to acheive that I would have to do a many to many relation ship and assign two different submenus subjects --->
jona
to one menu subjec. Well since I had quite bit of data right now I have decided to take the approach of LEFT OUTER JOIN two different tables similar in content which are dkb and cdkb tables. since dkb is different in css and html design and require more data and in this case coming from another table I have wanted to have dbl tables double table to dump data together with dkb since those data goes together in one page and they depend on another to satisfied page2.php which require data and information from those two tables.
jona
I think that the design of having a many to many relationship to have several submenu subjects to one menu subject was quite a good idea but it would be crazy too redesign the some tables that has a quite a bit of information.
jona
hope I have clarified your concerns in your last design you have put up. Have to say that the price in dkb won't be use since I use the price field of the dbl table that combine together with dkb to display it's content. The price field in dkb still there because I have made a copy pf cdkb and I have forgot to erase the price field which I won't use since page2.php uses dbl price field to show up the prices of the items inside dkb.
jona
@Ron your edited query worked... Some new issues arises now ï will post them later.Thank you Ron
jona
@Ron I have edited the script above with some issues that has come to present afterward.
jona