H Raval
H Raval

Reputation: 1903

Mysql select query with temp table

I want to get all child from my table of specified parent. for this i am using following code but i am getting error.

I have tried same code in sql by using 'with' clause but as in mysql we cant use 'with' clause so i am using this. I found this form here.

Here is my code

 Select Ct.* from 
(Select * from data where parent_id=1
    Union All 
    Select T.* From data T Join  CT on T.parent_id=CT.id
) CT

And i am getting this error

46 - Table 'db_wtg.ct' doesn't exist 

Please help me.

Upvotes: 2

Views: 276

Answers (1)

Wes Dean
Wes Dean

Reputation: 81

I am going to assume you are using MySQL. If that is the case, MySQL table names are case sensitive. You are creating your temp table as "CT" and trying to select from a table "Ct" that doesn't exist.

Upvotes: 1

Related Questions