Solved

Incorrect Syntax near the Keyword 'WHERE'

Posted on 2009-07-10
5
248 Views
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
0
Comment
Question by:doramail05
  • 3
5 Comments
 
LVL 31

Accepted Solution

by:
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
0
 
LVL 41

Expert Comment

by:pcelba
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.
0
 
LVL 31

Expert Comment

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

Author Comment

by:doramail05
ID: 24821451
resolved..

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";
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24821460
doramail05,

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

www.SQLHub.com
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now