Solved

which syntax is the correct sql syntax for working with inner join?

Posted on 2014-03-07
2
251 Views
Last Modified: 2014-03-07
// This way works fine in FireBird Dabatase

 Select distinct A.* from GlCli A
 inner join CFCLI1 B on (B.codcli=a.codcli and B.codempresa=1 and B.tipocli='C')
 where (lower(A.apelido) like '%teste%')
 or (lower(A.nome) like '%teste%')
 or (A.CGC like '%teste%')


// This way doesn't work in FireBird but works in MSSQL

Select distinct A.* from GlCli A
inner join CFCLI1 B on B.codcli=a.codcli
Where B.codempresa=1
  and B.tipocli='C')
  And (lower(A.apelido) like '%teste%')
or (lower(A.nome) like '%teste%')
 or (A.CGC like '%teste%')

Open in new window


Thanks
Alex
0
Comment
Question by:hidrau
[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
2 Comments
 
LVL 11

Accepted Solution

by:
David Kroll earned 500 total points
ID: 39913327
They're both correct.  I prefer to have all conditions related to a join in the actual join code, like the top example.  It's just easier to see every condition in one place for me.
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 39913474
thanks very much
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

615 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