Aadi
Aadi

Reputation: 7109

Mysql select multiple colomn from non related tables

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.

Upvotes: 0

Views: 620

Answers (3)

Your Common Sense
Your Common Sense

Reputation: 157870

If there is no relation between these two tables, you just shouldn't try to retrieve it using single query. It is senseless.

Upvotes: 0

Salil
Salil

Reputation: 47482

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

Upvotes: 1

aioobe
aioobe

Reputation: 420961

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.

Upvotes: 0

Related Questions