Dear Expert,
I have 2 tables as the following,
Table : Product
Column : ID, Code, Name
Table : Trx
Column : Trx_ID, Trx_Date, Product_ID
How can perform the following query in MSSQL or is there any other way
to perform the same query ??? For you info I can do this in Sybase and
it's work fine. Thank you.
================================================== ==========
Select Trx.Product_ID,
(Select Produc.Code
From Product
Where Product.ID = Trx.Product_ID) as Product_Code
From Trx
Where Product_Code = '0001'
================================================== ==========
Regards,
Chen Fock Siong
2004-05-27 4 1541
On 26 May 2004 21:00:56 -0700, Chen Fock Siong wrote: Dear Expert,
I have 2 tables as the following,
Table : Product Column : ID, Code, Name
Table : Trx Column : Trx_ID, Trx_Date, Product_ID
How can perform the following query in MSSQL or is there any other way to perform the same query ??? For you info I can do this in Sybase and it's work fine. Thank you.
================================================= =========== Select Trx.Product_ID, (Select Produc.Code From Product Where Product.ID = Trx.Product_ID) as Product_Code From Trx Where Product_Code = '0001' ================================================= ===========
Regards, Chen Fock Siong 2004-05-27
Hi Chen,
SELECT Trx.Product_ID, Product.Code
FROM Trx
INNER JOIN Product
ON Product.ID = Trx.Product_ID
WHERE Product_Code = '0001'
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
I'm not sure, I don't know the ins and outs of the syntax you are
using or what you want but:
this may be helpful?
select t.Product_ID, p.Code as Product_Code
from Trx t
join Product p
on p.ID = t.Product_ID
Where p.Code = '0001' fs****@biztrak.biz (Chen Fock Siong) wrote in message news:<f6**************************@posting.google. com>... Dear Expert,
I have 2 tables as the following,
Table : Product Column : ID, Code, Name
Table : Trx Column : Trx_ID, Trx_Date, Product_ID
How can perform the following query in MSSQL or is there any other way to perform the same query ??? For you info I can do this in Sybase and it's work fine. Thank you.
================================================== ========== Select Trx.Product_ID, (Select Produc.Code From Product Where Product.ID = Trx.Product_ID) as Product_Code From Trx Where Product_Code = '0001' ================================================== ==========
Regards, Chen Fock Siong 2004-05-27
In Standard SQL a WHERE clause may only refer to the column names in the
base table or a derived table. This is the rule that MS SQLServer uses. If
you nest your query inside a derived table then it will work but, as others
have suggested, there are probably more efficient ways of getting the result
you want.
SELECT product_id, product_code
FROM
(SELECT Trx.product_id,
(SELECT Product.Code
FROM Product
WHERE Product.ID = Trx.Product_ID) AS product_code
FROM Trx) AS T
WHERE product_code = '0001'
--
David Portas
SQL Server MVP
--
Sybase does NOT follow the ANSI standards. You also used TWO names
for the same data element. In a correct data model, there is no such
thing as an "ID"; it is the identifier of something. Why is a
product_code different from a product_id? Is this what you meant?
Without any DDL or a usable spec, we can only guess.
SELECT TRX.product_id, '1001'
FROM TRX, Products
WHERE Products.product_id = TRX.product_id; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pedro Fonseca |
last post by:
Greetings!
Can someone please help me to crack this problem? I have 4 tables:
Subject, Forum, Topic and Post. A Subject groups various Forums, a
Forum groups various Topics, and a Topic groups...
|
by: Nhmiller |
last post by:
This is directly from Access' Help:
"About designing a query
When you open a query in Design view, or open a form, report, or datasheet and
show the Advanced Filter/Sort window (Advanced...
|
by: doar123 |
last post by:
Hi,
This is my basic sql shape query:
------------------------------------------------------------
SHAPE {select * from tbl1}
APPEND({SELECT * FROM tbl2 where field1=1} AS RS2 RELATE field TO...
|
by: Woodies_46 |
last post by:
Hi all,
I'm just a little bit stuck... what i have is a form with tick boxs and
text boxs and stuff like that on it and a search button.
What I would like to be able to do is for the user to...
|
by: Matt C |
last post by:
Problem is that I can't really put all the details in here because of an
NDA. What's going on is that a query with multiple left joins is
apparently spooking mySQL. Server doesn't crash but I get:...
|
by: |
last post by:
I'm planning to transport a desktop application to the web. A spin-off of
this application has already been put on the web by another programmer. He
used ColdFusion with MS SQL, Access, VC, and...
|
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ |
last post by:
I am running Access 2007. I have a report that I want to filter. I
can go into Advanced...Advanced Filter/Sort... and setup a filter that
works fine on the report when I apply it. When in this...
|
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ |
last post by:
I am running Access 2007. I have a report that I want to filter. I
can go into Advanced...Advanced Filter/Sort... and setup a filter that
works fine on the report when I apply it. When in this...
|
by: mbatestblrock |
last post by:
I think I have a rather advanced question that I was hoping to find some good help with. I am still pretty new to VBA and I know that doesn't help my situation here. But here is what I am trying to...
|
by: rajendrsedhain |
last post by:
Hi,
I have 1 checkboxlist, 5 dropdownlits and three textboxes.I have to write the SQL query and c# code for that advanced search.
<asp:CheckBoxList ID="reposotoryCheckBoxList" runat="server"...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |