tags:

views:

35

answers:

3

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
Thank you.I don't know that this is these much simple
Ajith
@Ajith: thats going to give you count(rootpath) * count(savecategory) results--is that really what you want?
egrunin
Sure. It will return all combinations. The final list could be filtered using the `WHERE` construct.
aioobe
+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
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