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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 42

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query 5 44
Return array 3 20
T-SQL Query - Group By Year 3 29
Access 2010 - Issue Viewing Records Added to a Linked SQL Table 13 46
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

749 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