[{"data":1,"prerenderedAt":1141},["ShallowReactive",2],{"blog-\u002Fblog\u002Fsql-select-where-filtering":3},{"id":4,"title":5,"body":6,"description":1127,"difficulty":1128,"extension":1129,"framework":1130,"frameworkSlug":76,"meta":1131,"navigation":110,"order":91,"path":1132,"qaPath":1133,"seo":1134,"stem":1135,"subtopic":1136,"topic":1137,"topicSlug":1138,"updated":1139,"__hash__":1140},"blog\u002Fblog\u002Fsql-select-where-filtering.md","SQL SELECT & WHERE — Filtering Rows the Right Way",{"type":7,"value":8,"toc":1116},"minimark",[9,14,32,67,71,243,250,254,263,420,424,460,548,562,566,589,752,756,770,865,875,879,889,941,947,951,964,1075,1079,1112],[10,11,13],"h2",{"id":12},"the-shape-of-every-sql-query","The shape of every SQL query",[15,16,17,18,22,23,27,28,31],"p",{},"Every SQL query you will ever write starts with ",[19,20,21],"code",{},"SELECT",". It tells the database\n",[24,25,26],"strong",{},"which columns to return"," and, via the clauses that follow, which rows to\ninclude, how to sort them, and how many to fetch. Understanding what happens\nin which order matters — the database does ",[24,29,30],{},"not"," execute a query top to bottom.",[15,33,34,35,38,39,38,42,38,45,38,48,51,52,38,54,38,57,60,61,63,64,66],{},"The logical order is: ",[19,36,37],{},"FROM"," → ",[19,40,41],{},"JOIN",[19,43,44],{},"WHERE",[19,46,47],{},"GROUP BY",[19,49,50],{},"HAVING"," →\n",[19,53,21],{},[19,55,56],{},"ORDER BY",[19,58,59],{},"LIMIT",". That means column aliases defined in ",[19,62,21],{},"\nare invisible to ",[19,65,44],{}," — a common source of \"column does not exist\" errors.",[10,68,70],{"id":69},"select-choosing-columns","SELECT — choosing columns",[72,73,78],"pre",{"className":74,"code":75,"language":76,"meta":77,"style":77},"language-sql shiki shiki-themes github-light github-dark","-- All columns (avoid in application code)\nSELECT * FROM orders;\n\n-- Named columns with aliases\nSELECT\n    id,\n    customer_id,\n    total_amount      AS total,\n    created_at        AS ordered_at\nFROM orders;\n\n-- Computed column\nSELECT\n    product_name,\n    unit_price,\n    quantity,\n    unit_price * quantity AS line_total\nFROM order_items\nWHERE order_id = 1042;\n","sql","",[19,79,80,89,105,112,118,124,130,136,148,159,166,171,177,182,188,194,200,217,225],{"__ignoreMap":77},[81,82,85],"span",{"class":83,"line":84},"line",1,[81,86,88],{"class":87},"sJ8bj","-- All columns (avoid in application code)\n",[81,90,92,95,98,101],{"class":83,"line":91},2,[81,93,21],{"class":94},"szBVR",[81,96,97],{"class":94}," *",[81,99,100],{"class":94}," FROM",[81,102,104],{"class":103},"sVt8B"," orders;\n",[81,106,108],{"class":83,"line":107},3,[81,109,111],{"emptyLinePlaceholder":110},true,"\n",[81,113,115],{"class":83,"line":114},4,[81,116,117],{"class":87},"-- Named columns with aliases\n",[81,119,121],{"class":83,"line":120},5,[81,122,123],{"class":94},"SELECT\n",[81,125,127],{"class":83,"line":126},6,[81,128,129],{"class":103},"    id,\n",[81,131,133],{"class":83,"line":132},7,[81,134,135],{"class":103},"    customer_id,\n",[81,137,139,142,145],{"class":83,"line":138},8,[81,140,141],{"class":103},"    total_amount      ",[81,143,144],{"class":94},"AS",[81,146,147],{"class":103}," total,\n",[81,149,151,154,156],{"class":83,"line":150},9,[81,152,153],{"class":103},"    created_at        ",[81,155,144],{"class":94},[81,157,158],{"class":103}," ordered_at\n",[81,160,162,164],{"class":83,"line":161},10,[81,163,37],{"class":94},[81,165,104],{"class":103},[81,167,169],{"class":83,"line":168},11,[81,170,111],{"emptyLinePlaceholder":110},[81,172,174],{"class":83,"line":173},12,[81,175,176],{"class":87},"-- Computed column\n",[81,178,180],{"class":83,"line":179},13,[81,181,123],{"class":94},[81,183,185],{"class":83,"line":184},14,[81,186,187],{"class":103},"    product_name,\n",[81,189,191],{"class":83,"line":190},15,[81,192,193],{"class":103},"    unit_price,\n",[81,195,197],{"class":83,"line":196},16,[81,198,199],{"class":103},"    quantity,\n",[81,201,203,206,209,212,214],{"class":83,"line":202},17,[81,204,205],{"class":103},"    unit_price ",[81,207,208],{"class":94},"*",[81,210,211],{"class":103}," quantity ",[81,213,144],{"class":94},[81,215,216],{"class":103}," line_total\n",[81,218,220,222],{"class":83,"line":219},18,[81,221,37],{"class":94},[81,223,224],{"class":103}," order_items\n",[81,226,228,230,233,236,240],{"class":83,"line":227},19,[81,229,44],{"class":94},[81,231,232],{"class":103}," order_id ",[81,234,235],{"class":94},"=",[81,237,239],{"class":238},"sj4cs"," 1042",[81,241,242],{"class":103},";\n",[15,244,245,246,249],{},"Prefer named columns over ",[19,247,248],{},"SELECT *"," in application code — a schema change\n(adding or reordering a column) silently breaks queries that depend on position.",[10,251,253],{"id":252},"where-filtering-rows","WHERE — filtering rows",[15,255,256,258,259,262],{},[19,257,44],{}," is evaluated against the raw table rows ",[24,260,261],{},"before"," any aggregation.\nIt accepts any boolean expression, including comparisons, ranges, pattern\nmatches, and NULL checks.",[72,264,266],{"className":74,"code":265,"language":76,"meta":77,"style":77},"-- Equality and inequality\nSELECT * FROM products WHERE category = 'Electronics';\nSELECT * FROM orders   WHERE status \u003C> 'cancelled';\n\n-- Range with BETWEEN (inclusive on both ends)\nSELECT * FROM orders WHERE total_amount BETWEEN 100 AND 500;\n\n-- Multiple conditions\nSELECT * FROM users\nWHERE country = 'US'\n  AND account_type = 'premium'\n  AND created_at >= '2026-01-01';\n",[19,267,268,273,297,321,325,330,360,364,369,380,392,405],{"__ignoreMap":77},[81,269,270],{"class":83,"line":84},[81,271,272],{"class":87},"-- Equality and inequality\n",[81,274,275,277,279,281,284,286,289,291,295],{"class":83,"line":91},[81,276,21],{"class":94},[81,278,97],{"class":94},[81,280,100],{"class":94},[81,282,283],{"class":103}," products ",[81,285,44],{"class":94},[81,287,288],{"class":103}," category ",[81,290,235],{"class":94},[81,292,294],{"class":293},"sZZnC"," 'Electronics'",[81,296,242],{"class":103},[81,298,299,301,303,305,308,310,313,316,319],{"class":83,"line":107},[81,300,21],{"class":94},[81,302,97],{"class":94},[81,304,100],{"class":94},[81,306,307],{"class":103}," orders   ",[81,309,44],{"class":94},[81,311,312],{"class":94}," status",[81,314,315],{"class":94}," \u003C>",[81,317,318],{"class":293}," 'cancelled'",[81,320,242],{"class":103},[81,322,323],{"class":83,"line":114},[81,324,111],{"emptyLinePlaceholder":110},[81,326,327],{"class":83,"line":120},[81,328,329],{"class":87},"-- Range with BETWEEN (inclusive on both ends)\n",[81,331,332,334,336,338,341,343,346,349,352,355,358],{"class":83,"line":126},[81,333,21],{"class":94},[81,335,97],{"class":94},[81,337,100],{"class":94},[81,339,340],{"class":103}," orders ",[81,342,44],{"class":94},[81,344,345],{"class":103}," total_amount ",[81,347,348],{"class":94},"BETWEEN",[81,350,351],{"class":238}," 100",[81,353,354],{"class":94}," AND",[81,356,357],{"class":238}," 500",[81,359,242],{"class":103},[81,361,362],{"class":83,"line":132},[81,363,111],{"emptyLinePlaceholder":110},[81,365,366],{"class":83,"line":138},[81,367,368],{"class":87},"-- Multiple conditions\n",[81,370,371,373,375,377],{"class":83,"line":150},[81,372,21],{"class":94},[81,374,97],{"class":94},[81,376,100],{"class":94},[81,378,379],{"class":103}," users\n",[81,381,382,384,387,389],{"class":83,"line":161},[81,383,44],{"class":94},[81,385,386],{"class":103}," country ",[81,388,235],{"class":94},[81,390,391],{"class":293}," 'US'\n",[81,393,394,397,400,402],{"class":83,"line":168},[81,395,396],{"class":94},"  AND",[81,398,399],{"class":103}," account_type ",[81,401,235],{"class":94},[81,403,404],{"class":293}," 'premium'\n",[81,406,407,409,412,415,418],{"class":83,"line":173},[81,408,396],{"class":94},[81,410,411],{"class":103}," created_at ",[81,413,414],{"class":94},">=",[81,416,417],{"class":293}," '2026-01-01'",[81,419,242],{"class":103},[10,421,423],{"id":422},"null-the-value-that-breaks-comparisons","NULL — the value that breaks comparisons",[15,425,426,429,430,432,433,436,437,440,441,444,445,448,449,451,452,455,456,459],{},[19,427,428],{},"NULL"," means unknown. Any comparison with ",[19,431,428],{}," — ",[19,434,435],{},"= NULL",", ",[19,438,439],{},"\u003C> NULL",",\n",[19,442,443],{},"> NULL"," — returns ",[19,446,447],{},"UNKNOWN",", which ",[19,450,44],{}," treats as false. The only correct\nway to test for NULL is ",[19,453,454],{},"IS NULL"," or ",[19,457,458],{},"IS NOT NULL",".",[72,461,463],{"className":74,"code":462,"language":76,"meta":77,"style":77},"-- WRONG: never returns any rows (NULL = NULL is UNKNOWN, not TRUE)\nSELECT * FROM orders WHERE coupon_code = NULL;\n\n-- CORRECT\nSELECT * FROM orders WHERE coupon_code IS NULL;       -- no coupon applied\nSELECT * FROM orders WHERE coupon_code IS NOT NULL;   -- coupon present\n",[19,464,465,470,492,496,501,526],{"__ignoreMap":77},[81,466,467],{"class":83,"line":84},[81,468,469],{"class":87},"-- WRONG: never returns any rows (NULL = NULL is UNKNOWN, not TRUE)\n",[81,471,472,474,476,478,480,482,485,487,490],{"class":83,"line":91},[81,473,21],{"class":94},[81,475,97],{"class":94},[81,477,100],{"class":94},[81,479,340],{"class":103},[81,481,44],{"class":94},[81,483,484],{"class":103}," coupon_code ",[81,486,235],{"class":94},[81,488,489],{"class":94}," NULL",[81,491,242],{"class":103},[81,493,494],{"class":83,"line":107},[81,495,111],{"emptyLinePlaceholder":110},[81,497,498],{"class":83,"line":114},[81,499,500],{"class":87},"-- CORRECT\n",[81,502,503,505,507,509,511,513,515,518,520,523],{"class":83,"line":120},[81,504,21],{"class":94},[81,506,97],{"class":94},[81,508,100],{"class":94},[81,510,340],{"class":103},[81,512,44],{"class":94},[81,514,484],{"class":103},[81,516,517],{"class":94},"IS",[81,519,489],{"class":94},[81,521,522],{"class":103},";       ",[81,524,525],{"class":87},"-- no coupon applied\n",[81,527,528,530,532,534,536,538,540,542,545],{"class":83,"line":126},[81,529,21],{"class":94},[81,531,97],{"class":94},[81,533,100],{"class":94},[81,535,340],{"class":103},[81,537,44],{"class":94},[81,539,484],{"class":103},[81,541,458],{"class":94},[81,543,544],{"class":103},";   ",[81,546,547],{"class":87},"-- coupon present\n",[15,549,550,551,554,555,558,559,459],{},"This also affects ",[19,552,553],{},"WHERE col \u003C> 'value'"," — rows where ",[19,556,557],{},"col"," is NULL are\nsilently excluded. If you want them included, add ",[19,560,561],{},"OR col IS NULL",[10,563,565],{"id":564},"in-and-not-in","IN and NOT IN",[15,567,568,571,572,575,576,579,580,436,582,584,585,588],{},[19,569,570],{},"IN"," is a clean shorthand for multiple ",[19,573,574],{},"OR"," conditions. ",[19,577,578],{},"NOT IN"," has a dangerous\nedge case: if the value list contains a ",[19,581,428],{},[19,583,578],{}," returns zero rows —\nbecause ",[19,586,587],{},"x \u003C> NULL"," is always UNKNOWN.",[72,590,592],{"className":74,"code":591,"language":76,"meta":77,"style":77},"-- IN: orders in a set of statuses\nSELECT * FROM orders WHERE status IN ('pending', 'processing', 'on_hold');\n\n-- NOT IN safe version (no NULLs in the list)\nSELECT * FROM products WHERE category_id NOT IN (3, 7, 12);\n\n-- If the list comes from a subquery that may return NULLs, use NOT EXISTS\nSELECT * FROM products p\nWHERE NOT EXISTS (\n    SELECT 1 FROM discontinued d WHERE d.product_id = p.id\n);\n",[19,593,594,599,635,639,644,681,685,690,701,714,748],{"__ignoreMap":77},[81,595,596],{"class":83,"line":84},[81,597,598],{"class":87},"-- IN: orders in a set of statuses\n",[81,600,601,603,605,607,609,611,613,616,619,622,624,627,629,632],{"class":83,"line":91},[81,602,21],{"class":94},[81,604,97],{"class":94},[81,606,100],{"class":94},[81,608,340],{"class":103},[81,610,44],{"class":94},[81,612,312],{"class":94},[81,614,615],{"class":94}," IN",[81,617,618],{"class":103}," (",[81,620,621],{"class":293},"'pending'",[81,623,436],{"class":103},[81,625,626],{"class":293},"'processing'",[81,628,436],{"class":103},[81,630,631],{"class":293},"'on_hold'",[81,633,634],{"class":103},");\n",[81,636,637],{"class":83,"line":107},[81,638,111],{"emptyLinePlaceholder":110},[81,640,641],{"class":83,"line":114},[81,642,643],{"class":87},"-- NOT IN safe version (no NULLs in the list)\n",[81,645,646,648,650,652,654,656,659,662,664,666,669,671,674,676,679],{"class":83,"line":120},[81,647,21],{"class":94},[81,649,97],{"class":94},[81,651,100],{"class":94},[81,653,283],{"class":103},[81,655,44],{"class":94},[81,657,658],{"class":103}," category_id ",[81,660,661],{"class":94},"NOT",[81,663,615],{"class":94},[81,665,618],{"class":103},[81,667,668],{"class":238},"3",[81,670,436],{"class":103},[81,672,673],{"class":238},"7",[81,675,436],{"class":103},[81,677,678],{"class":238},"12",[81,680,634],{"class":103},[81,682,683],{"class":83,"line":126},[81,684,111],{"emptyLinePlaceholder":110},[81,686,687],{"class":83,"line":132},[81,688,689],{"class":87},"-- If the list comes from a subquery that may return NULLs, use NOT EXISTS\n",[81,691,692,694,696,698],{"class":83,"line":138},[81,693,21],{"class":94},[81,695,97],{"class":94},[81,697,100],{"class":94},[81,699,700],{"class":103}," products p\n",[81,702,703,705,708,711],{"class":83,"line":150},[81,704,44],{"class":94},[81,706,707],{"class":94}," NOT",[81,709,710],{"class":94}," EXISTS",[81,712,713],{"class":103}," (\n",[81,715,716,719,722,724,727,729,732,734,737,740,743,745],{"class":83,"line":161},[81,717,718],{"class":94},"    SELECT",[81,720,721],{"class":238}," 1",[81,723,100],{"class":94},[81,725,726],{"class":103}," discontinued d ",[81,728,44],{"class":94},[81,730,731],{"class":238}," d",[81,733,459],{"class":103},[81,735,736],{"class":238},"product_id",[81,738,739],{"class":94}," =",[81,741,742],{"class":238}," p",[81,744,459],{"class":103},[81,746,747],{"class":238},"id\n",[81,749,750],{"class":83,"line":168},[81,751,634],{"class":103},[10,753,755],{"id":754},"like-pattern-matching","LIKE — pattern matching",[15,757,758,761,762,765,766,769],{},[19,759,760],{},"LIKE"," matches text with two wildcards: ",[19,763,764],{},"%"," (any sequence of characters) and\n",[19,767,768],{},"_"," (exactly one character).",[72,771,773],{"className":74,"code":772,"language":76,"meta":77,"style":77},"-- Products starting with 'Apple'\nSELECT * FROM products WHERE product_name LIKE 'Apple%';\n\n-- Email addresses at a specific domain\nSELECT * FROM users WHERE email LIKE '%@acme.com';\n\n-- Exactly 5-character SKU codes\nSELECT * FROM products WHERE sku LIKE '_____';\n",[19,774,775,780,802,806,811,834,838,843],{"__ignoreMap":77},[81,776,777],{"class":83,"line":84},[81,778,779],{"class":87},"-- Products starting with 'Apple'\n",[81,781,782,784,786,788,790,792,795,797,800],{"class":83,"line":91},[81,783,21],{"class":94},[81,785,97],{"class":94},[81,787,100],{"class":94},[81,789,283],{"class":103},[81,791,44],{"class":94},[81,793,794],{"class":103}," product_name ",[81,796,760],{"class":94},[81,798,799],{"class":293}," 'Apple%'",[81,801,242],{"class":103},[81,803,804],{"class":83,"line":107},[81,805,111],{"emptyLinePlaceholder":110},[81,807,808],{"class":83,"line":114},[81,809,810],{"class":87},"-- Email addresses at a specific domain\n",[81,812,813,815,817,819,822,824,827,829,832],{"class":83,"line":120},[81,814,21],{"class":94},[81,816,97],{"class":94},[81,818,100],{"class":94},[81,820,821],{"class":103}," users ",[81,823,44],{"class":94},[81,825,826],{"class":103}," email ",[81,828,760],{"class":94},[81,830,831],{"class":293}," '%@acme.com'",[81,833,242],{"class":103},[81,835,836],{"class":83,"line":126},[81,837,111],{"emptyLinePlaceholder":110},[81,839,840],{"class":83,"line":132},[81,841,842],{"class":87},"-- Exactly 5-character SKU codes\n",[81,844,845,847,849,851,853,855,858,860,863],{"class":83,"line":138},[81,846,21],{"class":94},[81,848,97],{"class":94},[81,850,100],{"class":94},[81,852,283],{"class":103},[81,854,44],{"class":94},[81,856,857],{"class":103}," sku ",[81,859,760],{"class":94},[81,861,862],{"class":293}," '_____'",[81,864,242],{"class":103},[15,866,867,868,870,871,874],{},"A leading ",[19,869,764],{}," (e.g., ",[19,872,873],{},"LIKE '%word'",") forces a full table scan — the index on\nthat column cannot be used. For full-text search, use a dedicated full-text\nindex or a search service instead.",[10,876,878],{"id":877},"distinct-removing-duplicates","DISTINCT — removing duplicates",[15,880,881,884,885,888],{},[19,882,883],{},"SELECT DISTINCT"," removes duplicate rows from the result. It operates on the\n",[24,886,887],{},"combination"," of all selected columns.",[72,890,892],{"className":74,"code":891,"language":76,"meta":77,"style":77},"-- Which countries have placed orders?\nSELECT DISTINCT country FROM customers WHERE created_at >= '2026-01-01';\n\n-- Which (customer_id, product_id) pairs have repeat purchases?\nSELECT DISTINCT customer_id, product_id FROM order_items;\n",[19,893,894,899,920,924,929],{"__ignoreMap":77},[81,895,896],{"class":83,"line":84},[81,897,898],{"class":87},"-- Which countries have placed orders?\n",[81,900,901,903,905,907,910,912,914,916,918],{"class":83,"line":91},[81,902,883],{"class":94},[81,904,386],{"class":103},[81,906,37],{"class":94},[81,908,909],{"class":103}," customers ",[81,911,44],{"class":94},[81,913,411],{"class":103},[81,915,414],{"class":94},[81,917,417],{"class":293},[81,919,242],{"class":103},[81,921,922],{"class":83,"line":107},[81,923,111],{"emptyLinePlaceholder":110},[81,925,926],{"class":83,"line":114},[81,927,928],{"class":87},"-- Which (customer_id, product_id) pairs have repeat purchases?\n",[81,930,931,933,936,938],{"class":83,"line":120},[81,932,883],{"class":94},[81,934,935],{"class":103}," customer_id, product_id ",[81,937,37],{"class":94},[81,939,940],{"class":103}," order_items;\n",[15,942,943,946],{},[19,944,945],{},"DISTINCT"," is processed after all rows are gathered and can be expensive on\nlarge result sets. If you find yourself using it to hide a join that multiplies\nrows, fix the join instead.",[10,948,950],{"id":949},"combining-conditions-with-and-or-not","Combining conditions with AND, OR, NOT",[15,952,953,954,956,957,960,961,963],{},"Operator precedence: ",[19,955,661],{}," binds tightest, then ",[19,958,959],{},"AND",", then ",[19,962,574],{},". Missing\nparentheses cause subtle logic bugs.",[72,965,967],{"className":74,"code":966,"language":76,"meta":77,"style":77},"-- BUG: OR binds last, so this returns ALL premium US users\n-- plus ALL users with status = 'trial' regardless of country\nSELECT * FROM users\nWHERE country = 'US' AND account_type = 'premium' OR status = 'trial';\n\n-- CORRECT: parentheses make the intent explicit\nSELECT * FROM users\nWHERE (country = 'US' AND account_type = 'premium')\n   OR status = 'trial';\n",[19,968,969,974,979,989,1021,1025,1030,1040,1062],{"__ignoreMap":77},[81,970,971],{"class":83,"line":84},[81,972,973],{"class":87},"-- BUG: OR binds last, so this returns ALL premium US users\n",[81,975,976],{"class":83,"line":91},[81,977,978],{"class":87},"-- plus ALL users with status = 'trial' regardless of country\n",[81,980,981,983,985,987],{"class":83,"line":107},[81,982,21],{"class":94},[81,984,97],{"class":94},[81,986,100],{"class":94},[81,988,379],{"class":103},[81,990,991,993,995,997,1000,1002,1004,1006,1009,1012,1014,1016,1019],{"class":83,"line":114},[81,992,44],{"class":94},[81,994,386],{"class":103},[81,996,235],{"class":94},[81,998,999],{"class":293}," 'US'",[81,1001,354],{"class":94},[81,1003,399],{"class":103},[81,1005,235],{"class":94},[81,1007,1008],{"class":293}," 'premium'",[81,1010,1011],{"class":94}," OR",[81,1013,312],{"class":94},[81,1015,739],{"class":94},[81,1017,1018],{"class":293}," 'trial'",[81,1020,242],{"class":103},[81,1022,1023],{"class":83,"line":120},[81,1024,111],{"emptyLinePlaceholder":110},[81,1026,1027],{"class":83,"line":126},[81,1028,1029],{"class":87},"-- CORRECT: parentheses make the intent explicit\n",[81,1031,1032,1034,1036,1038],{"class":83,"line":132},[81,1033,21],{"class":94},[81,1035,97],{"class":94},[81,1037,100],{"class":94},[81,1039,379],{"class":103},[81,1041,1042,1044,1047,1049,1051,1053,1055,1057,1059],{"class":83,"line":138},[81,1043,44],{"class":94},[81,1045,1046],{"class":103}," (country ",[81,1048,235],{"class":94},[81,1050,999],{"class":293},[81,1052,354],{"class":94},[81,1054,399],{"class":103},[81,1056,235],{"class":94},[81,1058,1008],{"class":293},[81,1060,1061],{"class":103},")\n",[81,1063,1064,1067,1069,1071,1073],{"class":83,"line":150},[81,1065,1066],{"class":94},"   OR",[81,1068,312],{"class":94},[81,1070,739],{"class":94},[81,1072,1018],{"class":293},[81,1074,242],{"class":103},[10,1076,1078],{"id":1077},"recap","Recap",[15,1080,1081,1083,1084,1086,1087,1089,1090,1092,1093,1095,1096,1099,1100,1102,1103,1105,1106,1108,1109,1111],{},[19,1082,21],{}," names the output columns; ",[19,1085,44],{}," filters the rows before they reach\nthe output. Key rules: use ",[19,1088,454],{}," \u002F ",[19,1091,458],{}," for NULL checks; avoid\n",[19,1094,578],{}," when the value list might contain NULLs; prefer ",[19,1097,1098],{},"NOT EXISTS"," instead.\nA leading ",[19,1101,764],{}," in ",[19,1104,760],{}," kills index use — reserve it for small tables or use\nfull-text search for large ones. Parenthesise complex ",[19,1107,959],{},"\u002F",[19,1110,574],{}," conditions\nto make precedence explicit.",[1113,1114,1115],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}",{"title":77,"searchDepth":91,"depth":91,"links":1117},[1118,1119,1120,1121,1122,1123,1124,1125,1126],{"id":12,"depth":91,"text":13},{"id":69,"depth":91,"text":70},{"id":252,"depth":91,"text":253},{"id":422,"depth":91,"text":423},{"id":564,"depth":91,"text":565},{"id":754,"depth":91,"text":755},{"id":877,"depth":91,"text":878},{"id":949,"depth":91,"text":950},{"id":1077,"depth":91,"text":1078},"How SELECT and WHERE work in SQL — column aliases, wildcard pitfalls, comparison operators, NULL handling, LIKE patterns, and IN vs EXISTS.","easy","md","SQL",{},"\u002Fblog\u002Fsql-select-where-filtering","\u002Fsql\u002Fbasics\u002Fselect-where",{"title":5,"description":1127},"blog\u002Fsql-select-where-filtering","SELECT & WHERE","Query Basics","basics","2026-06-20","WESszO2mdGQee_GQAgI7aWqLNN13Hyr_gA0k2ZOUztM",1782244088621]