hi,
here is the structure of db
CREATE TABLE [LOCATION] (
[Id] VARCHAR(38),
[ParentId] VARCHAR(38),
[Name] VARCHAR(50))
INSERT INTO [LOCATION] ([Id], [ParentId], [Name])
VALUES ('{000E12CF-0C0A-4991-8A38-6C1B1EA28A56}', '{35542804-DD2A-45EC-B7C9-1E3F358FEA23}', 'Singapore')
GO
INSERT INTO [LOCATION] ([Id], [ParentId], [Name])
VALUES ('{006C9BE7-E711-4DCB-8141-782A36F6DEFC}', '{A3BB1EBD-D17D-4465-BB9A-B3622E826707}', 'Nevada')
GO
INSERT INTO [LOCATION] ([Id], [ParentId], [Name])
VALUES ('{00B46FFB-091F-4DF2-8635-67056E60EC2D}', '{18EACAAA-178B-47BB-80C3-F4438ED490F6}', 'Qatar')
GO
and go on...
CREATE TABLE [SECTOR] (
[ID] VARCHAR(38),
[ParentId] VARCHAR(38),
[Name] VARCHAR(255))
GO
INSERT INTO [SECTOR] ([ID], [ParentId], [Name])
VALUES ('{04DD96C5-F838-49EA-8F32-610B926C6E9C}', '{B934848B-F2E0-4BCB-809C-65B312FAC066}', 'Library')
GO
INSERT INTO [SECTOR] ([ID], [ParentId], [Name])
VALUES ('{0636DAEF-8055-43E3-9053-4BF59E818829}', '{423ED5A4-5499-4115-8519-6D6D76FD084C}', 'Other Engineering')
GO
and ...
CREATE TABLE [Website] (
[ID] VARCHAR(38),
[HomePage] VARCHAR(512))
GO
INSERT INTO [Website] ([ID], [HomePage])
VALUES ('{16D04933-52D2-45F7-9FCB-1A1A7F5EB253}', 'www.yahoo.com')
GO
INSERT INTO [Website] ([ID], [HomePage])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', 'www.hotmail.com')
GO
....
CREATE TABLE [Web2Location] (
[Web_ID] VARCHAR(38),
[Location_ID] VARCHAR(38))
GO
INSERT INTO [Web2Location] ([Web_ID], [Location_ID])
VALUES ('{16D04933-52D2-45F7-9FCB-1A1A7F5EB253}', '{1B79459C-371D-4472-BBCF-578B6C950463}')
GO
INSERT INTO [Web2Location] ([Web_ID], [Location_ID])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', '{70476DF7-B4B8-417E-ACE8-735CEFB71197}')
GO
...
CREATE TABLE [Web2Sector] (
[Web_ID] VARCHAR(38),
[Sector_ID] VARCHAR(38))
GO
INSERT INTO [Web2Sector] ([Web_ID], [Sector_ID])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', '{0C020B48-580C-4389-B4E3-2EDBD88A4877}')
GO
INSERT INTO [Web2Sector] ([Web_ID], [Sector_ID])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', '{12150FF7-5323-4F26-8EE3-BBF25110C48D}')
GO
CREATE TABLE [WebAccount] (
[ID] VARCHAR(38),
[Web_ID] VARCHAR(38),
[Login] VARCHAR(255),
[Pass] VARCHAR(255))
GO
INSERT INTO [WebAccount] ([ID], [Web_ID], [Login], [Pass])
VALUES ('{00BB7207-1EB1-497E-9FFA-446531FA97CB}', '{817011C3-4E7F-4BD7-B2A6-B5C057A4A7C4}', 'Usman', 'pass')
GO
INSERT INTO [WebAccount] ([ID], [Web_ID], [Login], [Pass])
VALUES ('{4199B81B-AC1E-4DA9-9C5E-25482DDB3840}', '{26D04433-52D2-45F7-9FCB-1A1A7F5EB359}', 'test', 'test')
GO
=================End of query portion====================
Now what I want is, I have location and sector IDs and I want a list/records from WebAccount table that are relevent to given location and sector IDs matching from Web2Location and Web2Sector tables.
Please let me know if it make sense and thanks in advance.
4 1084
hi,
here is the structure of db
CREATE TABLE [LOCATION] (
[Id] VARCHAR(38),
[ParentId] VARCHAR(38),
[Name] VARCHAR(50))
INSERT INTO [LOCATION] ([Id], [ParentId], [Name])
VALUES ('{000E12CF-0C0A-4991-8A38-6C1B1EA28A56}', '{35542804-DD2A-45EC-B7C9-1E3F358FEA23}', 'Singapore')
GO
INSERT INTO [LOCATION] ([Id], [ParentId], [Name])
VALUES ('{006C9BE7-E711-4DCB-8141-782A36F6DEFC}', '{A3BB1EBD-D17D-4465-BB9A-B3622E826707}', 'Nevada')
GO
INSERT INTO [LOCATION] ([Id], [ParentId], [Name])
VALUES ('{00B46FFB-091F-4DF2-8635-67056E60EC2D}', '{18EACAAA-178B-47BB-80C3-F4438ED490F6}', 'Qatar')
GO
and go on...
CREATE TABLE [SECTOR] (
[ID] VARCHAR(38),
[ParentId] VARCHAR(38),
[Name] VARCHAR(255))
GO
INSERT INTO [SECTOR] ([ID], [ParentId], [Name])
VALUES ('{04DD96C5-F838-49EA-8F32-610B926C6E9C}', '{B934848B-F2E0-4BCB-809C-65B312FAC066}', 'Library')
GO
INSERT INTO [SECTOR] ([ID], [ParentId], [Name])
VALUES ('{0636DAEF-8055-43E3-9053-4BF59E818829}', '{423ED5A4-5499-4115-8519-6D6D76FD084C}', 'Other Engineering')
GO
and ...
CREATE TABLE [Website] (
[ID] VARCHAR(38),
[HomePage] VARCHAR(512))
GO
INSERT INTO [Website] ([ID], [HomePage])
VALUES ('{16D04933-52D2-45F7-9FCB-1A1A7F5EB253}', 'www.yahoo.com')
GO
INSERT INTO [Website] ([ID], [HomePage])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', 'www.hotmail.com')
GO
....
CREATE TABLE [Web2Location] (
[Web_ID] VARCHAR(38),
[Location_ID] VARCHAR(38))
GO
INSERT INTO [Web2Location] ([Web_ID], [Location_ID])
VALUES ('{16D04933-52D2-45F7-9FCB-1A1A7F5EB253}', '{1B79459C-371D-4472-BBCF-578B6C950463}')
GO
INSERT INTO [Web2Location] ([Web_ID], [Location_ID])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', '{70476DF7-B4B8-417E-ACE8-735CEFB71197}')
GO
...
CREATE TABLE [Web2Sector] (
[Web_ID] VARCHAR(38),
[Sector_ID] VARCHAR(38))
GO
INSERT INTO [Web2Sector] ([Web_ID], [Sector_ID])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', '{0C020B48-580C-4389-B4E3-2EDBD88A4877}')
GO
INSERT INTO [Web2Sector] ([Web_ID], [Sector_ID])
VALUES ('{26D04433-52D2-45F7-9FCB-1A1A7F5EB123}', '{12150FF7-5323-4F26-8EE3-BBF25110C48D}')
GO
CREATE TABLE [WebAccount] (
[ID] VARCHAR(38),
[Web_ID] VARCHAR(38),
[Login] VARCHAR(255),
[Pass] VARCHAR(255))
GO
INSERT INTO [WebAccount] ([ID], [Web_ID], [Login], [Pass])
VALUES ('{00BB7207-1EB1-497E-9FFA-446531FA97CB}', '{817011C3-4E7F-4BD7-B2A6-B5C057A4A7C4}', 'Usman', 'pass')
GO
INSERT INTO [WebAccount] ([ID], [Web_ID], [Login], [Pass])
VALUES ('{4199B81B-AC1E-4DA9-9C5E-25482DDB3840}', '{26D04433-52D2-45F7-9FCB-1A1A7F5EB359}', 'test', 'test')
GO
=================End of query portion====================
Now what I want is, I have location and sector IDs and I want a list/records from WebAccount table that are relevent to given location and sector IDs matching from Web2Location and Web2Sector tables.
Please let me know if it make sense and thanks in advance.
Try this: -
-
SELECT a.* FROM WebAccount a, Web2Location l
-
WHERE a.web_id=l.web_id
-
AND l.location_id = '{70476DF7-B4B8-417E-ACE8-735CEFB71197}'
-
UNION ALL
-
SELECT a.* FROM WebAccount a, Web2Sector S
-
WHERE a.web_id=s.web_id
-
AND s.sector_id = '{12150FF7-5323-4F26-8EE3-BBF25110C48D}'
-
-
Try this: -
-
SELECT a.* FROM WebAccount a, Web2Location l
-
WHERE a.web_id=l.web_id
-
AND l.location_id = '{70476DF7-B4B8-417E-ACE8-735CEFB71197}'
-
UNION ALL
-
SELECT a.* FROM WebAccount a, Web2Sector S
-
WHERE a.web_id=s.web_id
-
AND s.sector_id = '{12150FF7-5323-4F26-8EE3-BBF25110C48D}'
-
-
thanks amitpatel66, this help me a lot
Try this: -
-
SELECT a.* FROM WebAccount a, Web2Location l
-
WHERE a.web_id=l.web_id
-
AND l.location_id = '{70476DF7-B4B8-417E-ACE8-735CEFB71197}'
-
UNION ALL
-
SELECT a.* FROM WebAccount a, Web2Sector S
-
WHERE a.web_id=s.web_id
-
AND s.sector_id = '{12150FF7-5323-4F26-8EE3-BBF25110C48D}'
-
-
hi once again, I was going to implement this when i realize it doesn't solve the issue. how? lets see
suppose i select location India and sector IT(IDs) so it means query should return only accounts of sector IT that are located in India. But as it is now, it returns all accounts from IT sector located anywhere and combine them with India location accounts.
will you plz help me to solve this issue
hi once again, I was going to implement this when i realize it doesn't solve the issue. how? lets see
suppose i select location India and sector IT(IDs) so it means query should return only accounts of sector IT that are located in India. But as it is now, it returns all accounts from IT sector located anywhere and combine them with India location accounts.
will you plz help me to solve this issue
Tryh this: -
-
SELECT a.* FROM WebAccount a, Web2Location l,Web2Sector S
-
WHERE a.web_id=l.web_id
-
AND a.web_id = s.web_id
-
AND l.location_id = '{70476DF7-B4B8-417E-ACE8-735CEFB71197}'
-
AND s.sector_id = '{12150FF7-5323-4F26-8EE3-BBF25110C48D}'
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Starbuck |
last post by:
OK, first let me say that I am no DB person.
But I have a user here who keeps getting this error
whenever she does, whatever it is she does, with
databases...
A google search takes me to...
|
by: Mikel |
last post by:
I am trying to get around the problem "The expression you have entered
is too complex" for a select query. (The example below is not the
expression that is giving me headaches.)
So I am thinking...
|
by: ED |
last post by:
I am attempting to to write a query that has a numerous nested IIf
statements. The problem that I am having is that it is to long of a
query to be built in design mode and when I build it in sql...
|
by: Matt |
last post by:
Hi all, Thank you for taking the time.
I have a database with 45 tables on it. 44 tables are linked to a main
table through a one to one relationship.
My question is, is there no way i can...
|
by: Ben de Vette |
last post by:
Hi,
I'm using the querybuilder when updating a record in a table (Access).
However, I get a "Query is too complex" message.
The Primary key is autonumbered.
Why is it making such a complex...
|
by: arun |
last post by:
Query is too complex
--------------------------------------------------------------------------------
Hi, I was trying to solve this problem since last two days but couldn't
find any solution.
...
|
by: Randy Volkart |
last post by:
I'm trying to fix a glitch in a complex access database, and have a
fairly complex problem... unless there's some obscure easy fix I don't
know being fairly new with Access. Basically, the area...
|
by: kawaks40 |
last post by:
Hi everyone :)
I just recently started using access/sql.
and right away I ran into this problem "SQL expression too complex"
I google'd a lot on what it means, and the only workaround I've...
|
by: Eric Davidson |
last post by:
DB2 9.5
I keep geting the message.
SQL0101N The statement is too long or too complex. SQLSTATE=54001
When one of my sql statements takes over 60 seconds to compile the sql
statement.
Is...
|
by: crystal2005 |
last post by:
Hi,
I am having trouble with some complex SQL queries. I’ve got winestore database, taken from Web Database Application with PHP and MySQL book. And some question about queries as the following
...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |