Solved

Incorrect Syntax near the Keyword 'WHERE'

Posted on 2009-07-10
5
252 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
[X]
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
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 42

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

738 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