PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 27, 2022

[FIXED] How to solve warning on Mode.com: syntax error at or near "..."?

 April 27, 2022     sql, warnings     No comments   

Issue

I am new to SQL and through Miss Tina Huang, I came to know Mode.com, a website that provides quite a comprehensive tutorial of SQL. I encountered this problem and dont know how to fix it, can you guys help me:

SELECT
  west, 
  midwest, 
  northeast,
  midwest + northeast AS "midwest_northeast_combined"
 FROM tutorial.us_housing_units
 Where west > "midwest_northeast_combined"

And then get a warning like this:

Looks like something went wrong with your query.
org.postgresql.util.PSQLException: ERROR: syntax error at or near "midwest"
  Position: 1

Solution

"midwest_northeast_combined" column is unknown to the where clause, because in your query midwest + northeast AS "midwest_northeast_combined" evaluates after where clause ,so you have to repeat it in your where clause:

SELECT
  west, 
  midwest, 
  northeast,
  midwest + northeast AS "midwest_northeast_combined"
 FROM tutorial.us_housing_units
 Where west > midwest + northeast 


Answered By - eshirvana
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing