I have two table in mysql named rootpath with only one field 'root' and savecatogory with fields brandid,categoryid,name.There is no relation between these two tables.Now how can retrieve root,brandid,categoryid using single query.Please help me.
A:
Perhaps you're looking for
SELECT rootpath.root, savecatogoroy.brandid, savecatogory.categoryid
FROM rootpath, savecatogoroy
Another way is to use the UNION operator, which is well described here.
aioobe
2010-05-28 05:34:08
Thank you.I don't know that this is these much simple
Ajith
2010-05-28 05:36:34
@Ajith: thats going to give you count(rootpath) * count(savecategory) results--is that really what you want?
egrunin
2010-05-28 05:39:56
Sure. It will return all combinations. The final list could be filtered using the `WHERE` construct.
aioobe
2010-05-28 05:43:12
+1
A:
Why you need that because
Consider example rootpath has 5 rows
Consider example savecatogoroy has 5 rows
SELECT r.root, s.brandid, s.categoryid FROM rootpath r, savecatogoroy s
Then it gives you 5*5 = 25 results
Salil
2010-05-28 05:40:59
A:
If there is no relation between these two tables, you just shouldn't try to retrieve it using single query. It is senseless.
Col. Shrapnel
2010-05-28 05:45:26