Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

2 select statements

2 posts in General Discussion Last posting was on 2005-08-09 16:33:52.0Z
MJN Posted on 2005-08-04 15:56:57.0Z
From: "MJN" <SpamFilterOnlychuck1rar@yahoo.com>
Newsgroups: ianywhere.public.general
Subject: 2 select statements
Lines: 55
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: zaq3d73a998.zaq.ne.jp
X-Original-NNTP-Posting-Host: zaq3d73a998.zaq.ne.jp
Message-ID: <42f23ac9$1@forums-1-dub>
Date: 4 Aug 2005 08:56:57 -0700
X-Trace: forums-1-dub 1123171017 61.115.169.152 (4 Aug 2005 08:56:57 -0700)
X-Original-Trace: 4 Aug 2005 08:56:57 -0700, zaq3d73a998.zaq.ne.jp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4669
Article PK: 8479

This is a repost from the main asa general group.
Sorry for the repetition but need to find an answer soon.

How can I compbine the below two select staements to retrieve the values I
require from the conditions below?

I have loaded a new table BT_ITEMS where the FK has been left null for now.
This table columns and rows come from other tables that still exist in the
schema.
Now I am trying to update the FK ("bt_items"."c_buy_id") values for the
table by using the below two selct statements.

So how I am trying to do this is something like this:
set "bt_items"."c_buy_id" = "course_bought"."c_buy_id"
where S1."sales"."c_code" = S2."sales"."c_code" and
S1."courses"."name" = S2."campaign"."name"


//Select1 (S1)

SELECT "course_bought"."c_buy_id",
"sales"."course_no",
"courses"."name",
"sales"."c_code"
FROM "course_bought",
"courses",
"sales"
WHERE ( "sales"."course_no" = "courses"."course_no" ) and
( "sales"."sales_id" = "course_bought"."sales_id" ) and
( ( "sales"."course_no" > 0 ) AND
( "courses"."classification" = 'BT' ) )


//Select2 (S2)

SELECT "sales"."c_code",
"sales"."course_no",
"sales"."product_no",
"sales"."service_no",
"campaign"."name",
"sales"."c_id",
"bt_items"."c_buy_id",
"bt_items"."item_id"
FROM {oj "sales" LEFT OUTER JOIN "courses" ON "sales"."course_no" =
"courses"."course_no" LEFT OUTER JOIN "course_bought" ON "sales"."sales_id"
= "course_bought"."sales_id"}, {oj "bt_items" RIGHT OUTER JOIN
"course_bought" ON "bt_items"."c_buy_id" = "course_bought"."c_buy_id"},
"campaign"
WHERE ( "sales"."c_id" = "campaign"."c_id" ) and
( ( "campaign"."c_type" = 'BT' ) )
ORDER BY "sales"."c_code" ASC


Reg Domaratzki (iAnywhere Solutions) Posted on 2005-08-09 16:33:52.0Z
From: "Reg Domaratzki \(iAnywhere Solutions\)" <FirstName.LastName@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <42f23ac9$1@forums-1-dub>
Subject: Re: 2 select statements
Lines: 79
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
X-Original-NNTP-Posting-Host: rdomarat-xp.sybase.com
Message-ID: <42f8daec$1@forums-2-dub>
X-Original-Trace: 9 Aug 2005 09:33:48 -0700, rdomarat-xp.sybase.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 9 Aug 2005 09:33:49 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 9 Aug 2005 09:33:52 -0700
X-Trace: forums-1-dub 1123605232 10.22.108.75 (9 Aug 2005 09:33:52 -0700)
X-Original-Trace: 9 Aug 2005 09:33:52 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4677
Article PK: 8478

This isn't a great question for the newsgroup. The person that knows your
schema best is you, and I don't have the time available to learn your schema
and respond with an answer. The lack of other responses indicates to me
that other people don't have the time or inclination either.

Would it be possible to re-word your question with a much simpler schema?

--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

"MJN" <SpamFilterOnlychuck1rar@yahoo.com> wrote in message
news:42f23ac9$1@forums-1-dub...
>
> This is a repost from the main asa general group.
> Sorry for the repetition but need to find an answer soon.
>
> How can I compbine the below two select staements to retrieve the values I
> require from the conditions below?
>
> I have loaded a new table BT_ITEMS where the FK has been left null for
now.
> This table columns and rows come from other tables that still exist in the
> schema.
> Now I am trying to update the FK ("bt_items"."c_buy_id") values for the
> table by using the below two selct statements.
>
> So how I am trying to do this is something like this:
> set "bt_items"."c_buy_id" = "course_bought"."c_buy_id"
> where S1."sales"."c_code" = S2."sales"."c_code" and
> S1."courses"."name" = S2."campaign"."name"
>
>
> //Select1 (S1)
>
> SELECT "course_bought"."c_buy_id",
> "sales"."course_no",
> "courses"."name",
> "sales"."c_code"
> FROM "course_bought",
> "courses",
> "sales"
> WHERE ( "sales"."course_no" = "courses"."course_no" ) and
> ( "sales"."sales_id" = "course_bought"."sales_id" ) and
> ( ( "sales"."course_no" > 0 ) AND
> ( "courses"."classification" = 'BT' ) )
>
>
> //Select2 (S2)
>
> SELECT "sales"."c_code",
> "sales"."course_no",
> "sales"."product_no",
> "sales"."service_no",
> "campaign"."name",
> "sales"."c_id",
> "bt_items"."c_buy_id",
> "bt_items"."item_id"
> FROM {oj "sales" LEFT OUTER JOIN "courses" ON "sales"."course_no" =
> "courses"."course_no" LEFT OUTER JOIN "course_bought" ON
"sales"."sales_id"
> = "course_bought"."sales_id"}, {oj "bt_items" RIGHT OUTER JOIN
> "course_bought" ON "bt_items"."c_buy_id" = "course_bought"."c_buy_id"},
> "campaign"
> WHERE ( "sales"."c_id" = "campaign"."c_id" ) and
> ( ( "campaign"."c_type" = 'BT' ) )
> ORDER BY "sales"."c_code" ASC
>
>
>