Incorrect Syntax near the Keyword 'WHERE'

Posted on 2009-07-10
Last Modified: 2012-05-07
i try to get the row where field sol.so_bo_suffix is not equal to NULL / Empty.

string strSQLget_selectrow = "Select * FROM sales_order so INNER JOIN sales_order_line sol WHERE sol.so_bo_suffix IS NOT NULL";

MSSQL Server 2005 Express
Question by:doramail05
  • 3
LVL 31

Accepted Solution

RiteshShah earned 500 total points
ID: 24821409
try something like this

Select * FROM sales_order so INNER JOIN sales_order_line sol on so.keyfield=sol.keyfield WHERE sol.so_bo_suffix IS NOT NULL
LVL 41

Expert Comment

ID: 24821413
You need to define the JOIN condition which connects lines to sales_order table, e.g.:

string strSQLget_selectrow =
"Select * FROM sales_order so INNER JOIN sales_order_line sol ON so.order_num = sol.order_num WHERE sol.so_bo_suffix IS NOT NULL";

You have to replace the column name by the one which exists in your tables.
LVL 31

Expert Comment

ID: 24821415
You are missing "ON" clause in which you have to define common field between two table.

Author Comment

ID: 24821451

string strSQLget_selectid = "Select * FROM sales_order so INNER JOIN sales_order_line sol on so.so_order_no = sol.so_order_no WHERE sol.so_bo_suffix IS NOT NULL";
LVL 31

Expert Comment

ID: 24821460

glad to help!!!, BTW, I was expecting "A" grade but awarded "B" grade, can you please tell me why "B" grade? If I am lacking something in my answer than your comment will help me to improve my own answer quality.

Ritesh Shah

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Live Storage Vmotion VMs with shared VMDK 10 59
SQL Help 27 45
SQL SELECT query help 7 41
SQL server vNext 18 29
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question