Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in SQL (SELECT and LEFT Join) How give id first table?

I have sql select:

SELECT * 
FROM `fclients` AS F 
LEFT JOIN `fclients_sequens` AS FS ON F.category = FS.category 
ORDER by FS.num

AND I get results:

result select sql

Then, for given id in first table, I make sql query:

SELECT *, fclients.id as fclientsID 
FROM `fclients` AS F 
LEFT JOIN `fclients_sequens` AS FS ON F.category = FS.category 
ORDER by FS.num

and I get an error:

#1054 - Unknown column 'fclients.id' in 'field list'

Tell me please how give id fist column (id=37)?

like image 575
Strannik Avatar asked Nov 27 '25 15:11

Strannik


1 Answers

You need to use the alias F when you reference the column ID

SELECT *, F.id...
like image 52
Adam Wenger Avatar answered Nov 29 '25 05:11

Adam Wenger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!