473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Checking for mismatch entries in two tables (Urgent Please)

There are two tables in our database Businessmaster and locationmaster
Businessmaster has the following fields like contentid, businessname, businesstype, location, city, state, country, zipcode, citylocid, statelocid and the locationmaster has the fields like contentid, location, city, state, country and I need to fetch all those mismatch records inner joining Businessmaster table and locationmaster table in which city and state are not the same in both the tables.

Here is the query which I have written

select b.contentid as Bcontentid, b.businessname as Bbusnessname, b.businesstype as Bbusinesstype , b.location as Blocation,
b.city as Bcity, b.state as Bstate, b.country as Bcountry,
b.zipcode as Bzipcode, b.crdate Bcrdate, b.isapproved Bisapproved, b.titleurl as Btitleurl, b.countrylocid Bcountrylocid,
b.statelocid as Bstatelocid, b.citylocid Bcitylocid,
l.contentid as Lcontentid,l.location as Llocation, l.city as Lcity, l.state as Lstate, l.country as Lcountry
from businessmaster b inner join locationmaster l
on b.citylocid = l.contentid
where b.isapproved=1
order by contentid, city, state, country

The above query fetches all those records from businessmater and locationmaster where b.citylocid=l.contentid
but I want to fetch only those mismatch records where the city and state mismatches for the given b.citylocid or l.contentid

In other words if the city given in Businessmaster is 'chennai' but the city in location master for the same contentid is reflected as 'bangalore' or if the state
given as 'tamilnadu' in Businessmaster and the state is reflected as 'Andhra Pradesh' in locationmaster then I should get only these records which are mismatching in terms of city and state for the given contentids or citylocids

Results should be displayed as given below fetching only the mismatch records (mismatch records of city and state)

b.city b.state b.country b.citylocid l.contentid chennai Tamil nadu India 274026 274026

l.city l.state l.country
madurai Tamil Nadu India
Nov 3 '08 #1
2 2478
ck9663
2,878 Expert 2GB
Try adding it on your WHERE clause.

Expand|Select|Wrap|Line Numbers
  1.  
  2. where b.isapproved=1 and (b.city <> l.city or b.state <> l.state)
  3.  
  4.  
Happy coding!

-- CK
Nov 3 '08 #2
Thank you for your reply. I will try the query
Nov 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Advocated | last post by:
This is a part of my code: <snipped> #define MAX_LINE_LENGTH 256 typedef struct { char *name; void (*function)(void); } COMMAND; void progCmd(void); void prog2Cmd(void);
3
by: Don | last post by:
I've added a Setup and Deployment project to my Visual Studio 2005 Windows Application solution and have several OCX and DLL files that will be installed. But I can't seem to find any examples in...
3
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance, it is GREATLY appreciated. I'm wondering if there is a way to duplicate a function in regedit of find and find next for keywords programmatically,...
2
by: carllucas | last post by:
Bonehead question I'm sure, but please forgive the ignorance: Can anyone tell me whether there is a means with phpmyadmin to check the table entries in your database. For example if i had a table...
4
by: Jeff | last post by:
I have a vb.net application (2005) requiring session variables and want to test to make certain that the user's cookies are enabled. I can set a test session variable on one page and attempt to...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
3
by: Bruce Lawrence | last post by:
I've got a form that when it opens it prompts the user for 2 peices of information. The Asset and the Date. getasset = InputBox("Enter the Asset Number") If getasset = "" Then Exit Sub Else...
1
by: Max2006 | last post by:
Hi, I am truing to find a pattern for my Business Logic Layer to be able to work fine win ObjectDataSource's Update method. The challenge is ObjectDataSource is not able to work with an...
1
by: gokulraj84 | last post by:
This is my Coding. Application newApp = new Application(); // Response. // specifying the Source & Target file names // c:\\abc\\Source.doc; object Source...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.