Solved

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

Posted on 2014-03-07
2
247 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL order by with "over" statement and row_number() 11 57
Query to Add Late Tolerance 10 82
View SQL 2005 Job package 16 77
Present Absent from working date rage 11 49
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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