SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘country_code’ in ‘where clause’ (SQL: select posts
.*, categories
.parent_id
as laravel_through_key
from posts
inner join categories
on categories
.id
= posts
.category_id
where categories
.parent_id
= 200 and country_code
= EN and category_id
in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 133, 134, 135, 136, 137, 138, 139, 140, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 286, 287, 288, 289, 290, 291, 292, 293, 460, 461, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 595, 596, 597, 598, 599, 600, 601, 602, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 677, 678, 679, 680, 681, 682) and verified_email
= 1 and verified_phone
= 1)
when adding another country
{"success":false,"message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'country_code' in 'where clause' (SQL: select * from `posts` where `country_code` =
when
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a.country_code' in 'where clause' (SQL: SELECT sc.id, c.parent_id, count(*) as total FROM posts as a INNER JOIN categories as sc ON sc.id=a.category_id AND sc.active=1 INNER JOIN categories as c ON c.id=sc.parent_id AND c.active=1 WHERE a.country_code = :countryCode AND (a.verified_email=1 AND a.verified_phone=1) AND a.archived!=1 AND a.deleted_at IS NULL GROUP BY sc.id)
Advertisement
Answer
Please check your database table named ‘posts’ and confirm if a column named ‘country_code’ is present.
If ‘country_code’ is present, then consider changing WHERE a.country_code = :countryCode
to WHERE a.country_code = '$countryCode'
.
Note that I removed ‘:’ from ‘:countryCode’ and I replaced it with ‘$’ in ‘$countryCode’, with the assumption that you have a variable named $countryCode in your code.