Ambiguous column in where clause with qualified identifier - mysql
I get the following error:
ERROR 1052 (23000) at line 1: Column 'id' in where clause is ambiguous
Database: MySQL 5.5.30 (with all tables & columns in the schema)
SELECT cam.id, cam.name AS campaign_name, cam.subdomain, usr.id AS user_id, usr.email, usr.display_name AS user_display_name
FROM campaigns AS cam
INNER JOIN users AS usr
ON usr.id = cam.user_id
WHERE cam.state=2
AND (usr.email = "hello#me.com")
AND cam.id IN (105793,107290,106048,107107,15097,108580,107394,107560,108942,107670,107925,107056,106089,30931,106864,45868,107625,106878,106417,88858,106065,106758,3282,103372,4449,108440,107311,106239,105857,110712,110243,105939,107001,105950,107124,105882,106139,107548,432,107466,105942,107115,51342,106437,106482,107192,105867,106993,107667,103769,108745,49924,105763,105935,99140,107402,20637,21155,105788,89963,106421,70124,12304,4748,107015,109758,103145,107590,106968,110692,26533,24993,33660,107398,34584,49597,107518,108878,107036,107668,105410,107060,106135,29205,106026,79254,19132,108692,107572,106978,93445,105678,107386,105866,106449,112104,id,312012,308555,323625,314793,321195,310245,291101,306016,179787,308224,290484,318154,318116,70226,313982,311419,71197,320725,271482,317257,331048,316765,75626,76321,329973,314034,313681,313850,306487,317443,83760,314759,339990,323732,306470,330480,89979,304814,91365,92541,316037,315131,116866,315323,111116,316067,316164,197902,129172,319690,141828,313517,315838,317608,310268,315096,309004,290518,319317,316349,316365,336052,183055,321936,318115,316950,330521,331975,324045,315540,201025,315770,321558,317962,200887,317500,328721,320403,311716,315812,318661,344680,315843,317483,317588,258656,317936,329850,245554,344785,314865,316722,329550,314332,316360,291604,341029,261118,264395,335387,330797,315403,276508,275586,275717,281996,276689,276709,290611,276957,277804,278480,279042,279381,344612,317507,280753,329926,281838,304604,311660,287452,317401,292158,305459,287031,312338,330015,295562,343920,289372,289377,328036,313204,322422,289641,289457,289486,291896,289453,298416,316894,289474,289476,289491,289566,289586,289599,289672,289677,328909,293962,289720,289754,289745,289774,293484,330235,289898,303233,290083,290120,290242,290327,290359,290399,290438,290475,290555,290628,290872,291214,291418,291333,291652,291779,313939,292236,292340,314508,293046,293376,293185,342259,293263,293515,293600,294511,295262,293957,294073,317855,294397,311490,294691,298226,294861,295088,295145,302131,313369,296434,315662,310084,322252,297288,297360,297432,298203,298794,299262,333157,305860,304484,304422,304462,304649,327116,304487,304504,318641,304528,304574,312829,304617,304668,304632,304924,304658,318170,304651,304762,304771,304770,304806,305019,304831,305281,304892,304941,304990,305008,305040,305041,337272,305048,305107,305126,309925,305195,305256,305284,305334,305294,305327,305342,305405,305521,306679,305520,305546,305595,305650,305659,305732,305712,305779,305798,305819,305838,305873,319122,307946,305937,310949,306243,306112,306113,306120,306140,306142,322700,306197,307466,306263,313766,318790,306303,306344,306346,306374,306407,306406,306415,306445,306465,306486,306510,309524,341418,306687,309657,306759,308941,306751,306779,306756,306778,307202,308147,329657,330603,306859,320503,306849,306870,331402,306863,306928,306880,306894,306906,306918,306936,307479,306962,306970,306968,306982,306986,307001,307005,307008,309223,307007,307011,307061,307062,307092,308177,332228,307478,307127,328246,307161,337299,330104,307791,307412,307424,328480,307430,307447,307454,307473,307480,307512,307493,314340,307542,307526,307527,307545,307589,307623,336402,307652,307659,333206,307666,319975,307674,313887,310200,307713,307761,307771,309273,307817,307823,310259,307878,307889,312913,307976,308013,308021,308120,308174,308182,319795,308272,308290,333845,324412,308441,308450,308468,308479,308566,308525,308544,308561,308598,308616,308617,318255,308648,308651,308657,308663,308668,308671,335094,308680,311769,308872,334045,308717,308739,308788,308804,312547,308819,308827,308911,308904,309543,309015,309021,309052,309220,309079,309099,309163,309179,327520,309243,309236,314363,309263,309279,309285,309314,309364,309406,309457,309478,309495,309552,309952,309588,309613,309636,309638,309650,313116,310919,309734,314296,309811,309849,309882,325089,310459,338535,309931,309940,310023,310002,310007,310030,310032,318779,310081,310118,319304,310120,325833,310144,310145,310151,310204,310210,310278,329000,322690,310323,310383,317187,310442,310447,310451,310461,310488,311128,310545,310567,310566,310575,310597,310600,311042,310636,310661,310659,310666,310680,310707,310691,310709,310720,310722,310723,310725,314488,310736,310754,310762,310763,320101,310796,310894,310947,310953,312134,311039,311257,311200,311139,311152,311156,311164,311215,311218,311233,314467,311307,311313,311322,311333,311358,311379,311446,311448,315437,311530,311550,311570,311637,311638,311683,311702,311663,311699,311712,311739,311752,311808,311822,311826,342130,311881,311898,311907,325253,312032,312047,312050,312078,312098,313206,312165,312170,312188,312240,312241,312257,316515,312261,312302,312756,312340,312388,312459,322362,312453,312492,312501,312512,312568,312521,312543,314688,312584,312588,325194,312597,330651,312712,312821,312768,312809,325199,312857,312866,312871,312887,312891,312892,312906,312919,312928,312952,342782,312951,312968,312966,313020,313028,313057,313058,313062,313064,313071,327699,313471,313123,313193,324221,313270,313298,313300,313321,313354,313401,313408,314164,313479,344095,313554,314879,313582,313579,314849,313619,313620,313647,313674,313697,313715,313718,313721,313725,315051,313776,318773,313811,313857,333559,313843,313883,313920,313936,313974,320242,314247,315426,314032,314082,314085,314108,314112,314141,315142,314173,314229,314243,314664,314359,314365,314372,314400,314376,314395,314466,314468,314476,315731,314491,314492,316501,314875,314551,314562,314589,314614,314629,314651,314675,314652,314656,314751,315509,314770,314771,314834,314806,314860,314874,314916,315030,314923,314975,315021,315018,315019,315037,320761,337287,315047,315063,315139,315087,315102,315122,326907,315194,315200,315224,315232,315239,315252,315258,315318,315347,315357,315380,315388,338468,315395,315414,315420,316572,315441,335308,315453,315486,315488,317629,315565,315664,315686,315691,315707,315775,317867,315829,318320,315895,316394,315899,316178,315902,326518,316286,316030,316012,326614,316047,316062,316078,316128,316633,316151,316182,316189,319659,316822,316231,316238,316256,316267,321759,316282,317917,316372,316379,316402,316428,328069,316775,316457,316490,316467,316543,316586,316602,316616,316617,316646,320300,316685,316965,316739,328530,316790,316795,327353,316823,321203,316841,339982,330937,317245,316860,316881,316887,316892,316925,325234,342990,320909,331646,330988,320580,327576,317465,317054,323357,317149,317201,317239,317235,317243,319624,317355,317290,318297,317294,322359,320591,319131,317360,317410,317674,317533,317482,332117,317522,317556,317590,317613,317643,317673,319865,324529,317801,317866,323277,318733,317905,317909,318010,318056,318223,318146,318196,318208,318245,318262,318858,320332,322855,335628,321932,323584,325517,327285,326636,329112,327394,329130,328687,328625)
ORDER BY cam.id ASC
When I strip the "AND cam.id IN ()" part, it executes.
Why does this happen, although I have fully qualified the column (i.e. "cam.id" instead of "id")?
Things I tried:
removing the "AND cam.id" clause --> statement executes without error
using "campaigns.id" instead of "cam.id" --> error 1054 / "unknown column in where clause"
UPDATE it works, if I have only a few (say 5) items in the IN clause
I think that the root of the problem is in the following line:
AND cam.id IN (105793,107290,106048,107107,15097,108580,107394,107560,108942,107670,107925,107056,106089,30931,106864,45868,107625,106878,106417,88858,106065,106758,3282,103372,4449,108440,107311,106239,105857,110712,110243,105939,107001,105950,107124,105882,106139,107548,432,107466,105942,107115,51342,106437,106482,107192,105867,106993,107667,103769,108745,49924,105763,105935,99140,107402,20637,21155,105788,89963,106421,70124,12304,4748,107015,109758,103145,107590,106968,110692,26533,24993,33660,107398,34584,49597,107518,108878,107036,107668,105410,107060,106135,29205,106026,79254,19132,108692,107572,106978,93445,105678,107386,105866,106449,112104,id,312012,308555,323625,314793,321195,310245,291101,306016,179787,308224,290484,318154,318116,70226,313982,311419,71197,320725,271482,317257,331048,316765,75626,76321,329973,314034,313681,313850,306487,317443,83760,314759,339990,323732,306470,330480,89979,304814,91365,92541,316037,315131,116866,315323,111116,316067,316164,197902,129172,319690,141828,313517,315838,317608,310268,315096,309004,290518,319317,316349,316365,336052,183055,321936,318115,316950,330521,331975,324045,315540,201025,315770,321558,317962,200887,317500,328721,320403,311716,315812,318661,344680,315843,317483,317588,258656,317936,329850,245554,344785,314865,316722,329550,314332,316360,291604,341029,261118,264395,335387,330797,315403,276508,275586,275717,281996,276689,276709,290611,276957,277804,278480,279042,279381,344612,317507,280753,329926,281838,304604,311660,287452,317401,292158,305459,287031,312338,330015,295562,343920,289372,289377,328036,313204,322422,289641,289457,289486,291896,289453,298416,316894,289474,289476,289491,289566,289586,289599,289672,289677,328909,293962,289720,289754,289745,289774,293484,330235,289898,303233,290083,290120,290242,290327,290359,290399,290438,290475,290555,290628,290872,291214,291418,291333,291652,291779,313939,292236,292340,314508,293046,293376,293185,342259,293263,293515,293600,294511,295262,293957,294073,317855,294397,311490,294691,298226,294861,295088,295145,302131,313369,296434,315662,310084,322252,297288,297360,297432,298203,298794,299262,333157,305860,304484,304422,304462,304649,327116,304487,304504,318641,304528,304574,312829,304617,304668,304632,304924,304658,318170,304651,304762,304771,304770,304806,305019,304831,305281,304892,304941,304990,305008,305040,305041,337272,305048,305107,305126,309925,305195,305256,305284,305334,305294,305327,305342,305405,305521,306679,305520,305546,305595,305650,305659,305732,305712,305779,305798,305819,305838,305873,319122,307946,305937,310949,306243,306112,306113,306120,306140,306142,322700,306197,307466,306263,313766,318790,306303,306344,306346,306374,306407,306406,306415,306445,306465,306486,306510,309524,341418,306687,309657,306759,308941,306751,306779,306756,306778,307202,308147,329657,330603,306859,320503,306849,306870,331402,306863,306928,306880,306894,306906,306918,306936,307479,306962,306970,306968,306982,306986,307001,307005,307008,309223,307007,307011,307061,307062,307092,308177,332228,307478,307127,328246,307161,337299,330104,307791,307412,307424,328480,307430,307447,307454,307473,307480,307512,307493,314340,307542,307526,307527,307545,307589,307623,336402,307652,307659,333206,307666,319975,307674,313887,310200,307713,307761,307771,309273,307817,307823,310259,307878,307889,312913,307976,308013,308021,308120,308174,308182,319795,308272,308290,333845,324412,308441,308450,308468,308479,308566,308525,308544,308561,308598,308616,308617,318255,308648,308651,308657,308663,308668,308671,335094,308680,311769,308872,334045,308717,308739,308788,308804,312547,308819,308827,308911,308904,309543,309015,309021,309052,309220,309079,309099,309163,309179,327520,309243,309236,314363,309263,309279,309285,309314,309364,309406,309457,309478,309495,309552,309952,309588,309613,309636,309638,309650,313116,310919,309734,314296,309811,309849,309882,325089,310459,338535,309931,309940,310023,310002,310007,310030,310032,318779,310081,310118,319304,310120,325833,310144,310145,310151,310204,310210,310278,329000,322690,310323,310383,317187,310442,310447,310451,310461,310488,311128,310545,310567,310566,310575,310597,310600,311042,310636,310661,310659,310666,310680,310707,310691,310709,310720,310722,310723,310725,314488,310736,310754,310762,310763,320101,310796,310894,310947,310953,312134,311039,311257,311200,311139,311152,311156,311164,311215,311218,311233,314467,311307,311313,311322,311333,311358,311379,311446,311448,315437,311530,311550,311570,311637,311638,311683,311702,311663,311699,311712,311739,311752,311808,311822,311826,342130,311881,311898,311907,325253,312032,312047,312050,312078,312098,313206,312165,312170,312188,312240,312241,312257,316515,312261,312302,312756,312340,312388,312459,322362,312453,312492,312501,312512,312568,312521,312543,314688,312584,312588,325194,312597,330651,312712,312821,312768,312809,325199,312857,312866,312871,312887,312891,312892,312906,312919,312928,312952,342782,312951,312968,312966,313020,313028,313057,313058,313062,313064,313071,327699,313471,313123,313193,324221,313270,313298,313300,313321,313354,313401,313408,314164,313479,344095,313554,314879,313582,313579,314849,313619,313620,313647,313674,313697,313715,313718,313721,313725,315051,313776,318773,313811,313857,333559,313843,313883,313920,313936,313974,320242,314247,315426,314032,314082,314085,314108,314112,314141,315142,314173,314229,314243,314664,314359,314365,314372,314400,314376,314395,314466,314468,314476,315731,314491,314492,316501,314875,314551,314562,314589,314614,314629,314651,314675,314652,314656,314751,315509,314770,314771,314834,314806,314860,314874,314916,315030,314923,314975,315021,315018,315019,315037,320761,337287,315047,315063,315139,315087,315102,315122,326907,315194,315200,315224,315232,315239,315252,315258,315318,315347,315357,315380,315388,338468,315395,315414,315420,316572,315441,335308,315453,315486,315488,317629,315565,315664,315686,315691,315707,315775,317867,315829,318320,315895,316394,315899,316178,315902,326518,316286,316030,316012,326614,316047,316062,316078,316128,316633,316151,316182,316189,319659,316822,316231,316238,316256,316267,321759,316282,317917,316372,316379,316402,316428,328069,316775,316457,316490,316467,316543,316586,316602,316616,316617,316646,320300,316685,316965,316739,328530,316790,316795,327353,316823,321203,316841,339982,330937,317245,316860,316881,316887,316892,316925,325234,342990,320909,331646,330988,320580,327576,317465,317054,323357,317149,317201,317239,317235,317243,319624,317355,317290,318297,317294,322359,320591,319131,317360,317410,317674,317533,317482,332117,317522,317556,317590,317613,317643,317673,319865,324529,317801,317866,323277,318733,317905,317909,318010,318056,318223,318146,318196,318208,318245,318262,318858,320332,322855,335628,321932,323584,325517,327285,326636,329112,327394,329130,328687,328625)
if you'll look carefully you'll see that inside this huge list you accidentally entered "id" as one of the items.
your in list includes an identifier
...,112104,id,312012,...
^^-------------------- ???
Related
Unknown column 'r' in field list
I've been working on a SQL query for a project, and I face an error message when I want to use it. Here is the query itself : SELECT COUNT(r) AS auditMade, SUM(g.nbrMilkingCows) AS cowsAudited, AVG(r.gainPerCowPerYearTransition) AS averageGainTransition, AVG(r.gainPerCowPerYearLactation) AS averageGainLactation, AVG(r.totalGain) AS averageTotalGain, AVG(r.supplementalCostPerCow) AS averageSuppCost FROM `smart_calculator_infos` i INNER JOIN `smart_calculator_result` r ON r.idSmartCalculatorResult = i.idSmartCalculatorResult INNER JOIN `calculator_general_informations` g ON g.idSmartCalculatorInfo = i.idSmartCalculatorInfo WHERE i.idUser = 14 MySQL answers me "Unknown column 'r' in field list". But I dont really understand why I get an error here as I define r in my INNER JOIN. I'm kinda new at using SQL so maybe there is something pretty obvious I forgot, but I can't seem to understand what.
You can't count an alias itself, so the very first line of your query is what is causing the error: SELECT COUNT(r) To remedy this, you could use COUNT(*): SELECT COUNT(*) Or, you could count an actual column in the smart_calculator_result table, e.g. SELECT COUNT(r.idSmartCalculatorResult)
MySQL error validators can't seem to find in syntax
I'm trying to build an SQL-Query with MySQL-Version 5.7.27. I'm trying to make multiple left joins to the same table. At some point i get an error, that tells me, a column of the original table is unknown. I tried finding the syntax error in my query, but there can't seem to be an obvious one. I tried out some online SQL-validators. They keep telling me, my query is valid. After that i tried picking apart the query, to find out, what exactly i am working with before the left join that makes my query unable to function. Doing that actually showed me a result, that was including the column the error was telling me, that is missing. So maybe it is not a syntax error, but MySQL is validating things in a order different to what i know, trying to pick the "missing" column out of somewhere it actually doesn't exist. Changing the order of left joins actually solves the problem. I can't really do that, tho. The SQL is being generated by some functions. One for every part of the SQL. One for the "SELECT", one for the "FROM" and so on. So a working thing is joining the minimized versions of the "additional_agreement_fields" table before the other joins. Sadly the function for the "FROM" part is written ... in a very interesting way. So my best bet is adding the "additional_agreement_fields" joins after the function that creates the FROM. That attempt generated the SQL below. I get following error: Error Code: 1054. Unknown column 'customers.id' in 'on clause' So: - The parts of the query are working on their own - Execution until the point of the error holds a table that has the "missing column" - Changing the order of the joins solves the problem, but i can't just do that and i want to know, why it doesn't work in this order - Online-validators can't find any syntax errors - Logically i am just adding columns to a table that are not ambiguous and not removing any. Yet something becomes unable to be found SELECT DISTINCT (customers.id), companies.company_name AS 'Kunde -> Firmenname', vcpt_mail.tcom_value AS 'Kontakt -> TCom -> Email', v_contact_people.id AS 'Kontakt -> ID', v_contact_people.last_name AS 'Kontakt -> Nachname', A0.value AS 'Kunde -> Zusatzvereinbarung -> TestfeldB' FROM customers LEFT JOIN customer_types ON customer_types.id = customers.customer_type_id, v_customer_owners, companies LEFT JOIN (v_contact_people LEFT JOIN v_cp_tcoms AS vcpt_mail ON vcpt_mail.contact_person_id = v_contact_people.id AND vcpt_mail.ttid = 3 AND (vcpt_mail.type_label_access_path = '/Global' OR vcpt_mail.type_label_access_path LIKE '/Global%')) ON v_contact_people.company_id = companies.id AND v_contact_people.access_path LIKE '/Global%' LEFT JOIN (SELECT * FROM additional_agreement_fields WHERE name = 'TestfeldB' AND value = '5') AS A0 ON customers.id = A0.customer_id LEFT JOIN (SELECT * FROM additional_agreement_fields WHERE name = 'TestfeldC' AND value = '6') AS A1 ON customers.id = A1.customer_id WHERE v_customer_owners.customer_id = customers.id AND v_customer_owners.path LIKE '/Global%' AND customers.company_id = companies.id AND companies.deleted_at IS NULL AND customers.deleted_at IS NULL AND (A0.value = '5' AND A0.name = 'TestfeldB' OR A1.value = '6' AND A1.name = 'TestfeldC'); The expected result is a not empty table with 2 customers in it, i prepared to find and that are found, changing the join order. The result is an interrupted query with an error code. Error Code: 1054. Unknown column 'customers.id' in 'on clause'
Create view changes "... is null" to isnull() - but then doesn't work
I have a query like this: select a.*, (select group_concat(b.name) from b where b.id = a.id) as b_concat from a having b_concat is null This works correctly when executed directly. But I get errors when I put it into a view. The 'create view ...' statement works fine and creates the view. But when I do "select * from my_view", I get error: Error Code: 1356 View 'my_db.my_view' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them I then look at my view definition and mysql has changed "having b_concat is null" to "having isnull(b_concat)" - so in the view it now has: select a.*, (select group_concat(b.name) from b where b.id = a.id) as b_concat from a having isnull(b_concat) When I copy that sql and execute it directly, and I get error: Unknown column 'b_concat' in 'having clause' Question ... Is there a way to force mysql to not convert to "isnull()" - or maybe a way to make mysql know that "b_concat" is a derived field when it's inside isnull() ? Or is there something else I should do? Note - The table relationship is one 'a' to many 'b'. Thanks, Josh
Convert SELECT statement to an UPDATE statement in MySQL
I have already read a majority of this similarly asked question but due to the specific nature of most of the answers, none helped, or I was unable to apply the answer. I need to convert this SELECT statement into an UPDATE statement, the SELECT statement works just fine. SELECT sf_state_filings_cstm.recurrency_c, sf_state_filings_cstm.date_filed_c, sf_state_filings_cstm.status_c FROM sc_state_configuration_cstm INNER JOIN sc_state_configuration_sf_state_filings_1_c ON sc_state_configuration_cstm.id_c = sc_state_configuration_sf_state_filings_1_c.sc_state_c2445uration_ida INNER JOIN sf_state_filings_cstm ON sc_state_configuration_sf_state_filings_1_c.sc_state_configuration_sf_state_filings_1sf_state_filings_idb = sf_state_filings_cstm.id_c WHERE sc_state_configuration_cstm.id_c = '2d9b438e-01e1-ccb2-82e5-5721221114bb' This is what I have so far after working through the following errors: When I first wrote the update statement, I got: MySQL code error 1066: Not unique table/alias: ‘sf_state_filings_cstm Solution: Why does this SQL code give error 1066 (Not unique table/alias: 'user')? Then I got this error: 1052: Column ‘recurrency_c' in field list is ambiguous Solution: 1052: Column 'id' in field list is ambiguous Now I have this error: Error : Unknown column 'sc_state_configuration_cstm.id_c' in 'where clause' None of the below links have helped so far, or I was doing something wrong Unknown Column In Where Clause Unknown Column in Where Clause MySQL: "Unknown column in where clause" during Update Statement I have a feeling the answer has to do with using an alias as mentioned in one the links, using HAVING instead of WHERE, but just replacing WHERE with HAVING doesn't seem to work. Here is my syntax right now: UPDATE `my_database`.`sf_state_filings_cstm` LEFT OUTER JOIN sc_state_configuration_sf_state_filings_1_c AS joined_tables ON sc_state_configuration_cstm.id_c = sc_state_configuration_sf_state_filings_1_c.sc_state_c2445uration_ida LEFT OUTER JOIN sf_state_filings_cstm AS main_table ON sc_state_configuration_sf_state_filings_1_c.sc_state_configuration_sf_state_filings_1sf_state_filings_idb = sf_state_filings_cstm.id_c SET main_table.recurrency_c = 'Perpetual', main_table.expiration_date_c = '' WHERE sc_state_configuration_cstm.id_c = '2d9b438e-01e1-ccb2-82e5-5721221114bb' EDIT 1: Here is how the Tables have to be linked to each other: I also realized, I need to be doing a LEFT OUTER JOIN instead of an INNER JOIN. I have updated the above syntax. The middle table stores the id's from both tables. That's how the relationship is stored. If more information is needed, let me know. [SOLUTION] UPDATE sc_state_configuration_cstm LEFT OUTER JOIN sc_state_configuration_sf_state_filings_1_c ON sc_state_configuration_cstm.id_c = sc_state_configuration_sf_state_filings_1_c.sc_state_c2445uration_ida LEFT OUTER JOIN sf_state_filings_cstm ON sc_state_configuration_sf_state_filings_1_c.sc_state_configuration_sf_state_filings_1sf_state_filings_idb = sf_state_filings_cstm.id_c SET sf_state_filings_cstm.recurrency_c = 'Perpetual', sf_state_filings_cstm.expiration_date_c = null WHERE sc_state_configuration_cstm.id_c = '2d9b438e-01e1-ccb2-82e5-5721221114bb' Thanks to jyncka and a lot of other posts I read, where i noticed that when converting a SELECT to an UPDATE, they simply wrote UPDATE (table from the 'FROM' statement). I went back and noticed I had written: FROM sc_state_configuration_cstm
The error is telling you what's happening: id_c is not a column that exists in the sc_state_configuration_cstm table. If you do a DESCRIBE on sc_state_configuration_cstm it will show you the correct field name and you can drop that in instead of id_c. Or you might have used the wrong alias in your WHERE statement. Without knowing what your tables look like, it's difficult to say which is the case. Edit: I believe I see the problem. Here are the tables you are explicitly using in the statement: sc_state_configuration_sf_state_filings_1_c sf_state_filings_cstm But you are using this table in the WHERE clause: sc_state_configuration_cstm You need to join sc_state_configuration_cstm so that it can be used. It took me a minute to see it because sc_state_configuration_cstm and sf_state_filings_cstm look similar at first glance.
getting unknown column error even when the column is present in mysql table
select tab1.*( select a.* from fw_invi a left join fw_resp b on a.id=b.did, fw_resp fra left join( select * from fw_type ) tab4 on fra.qaild=tab4.qdetailid //this causing error )tab1 left join jos_users u on tab1.consu=u.id order by tab1.createdon desc On running the above query in mysql i am getting the following error,which should not be the case as the specified missing column is present in that table.i think i am doing the wrong nested table aliasing. Unknown column 'tab4.qdetailid' in 'on clause' 1.Why i am getting the error even though the column is present.? 2.Is my above query syntax correct? Thanks in advance.
* can't be used with aliases. Aliases are used for named columns.