|
|
Hi,
I have 2 tables ,say A and B.
A: (ID Col1 Col2)
B: (ID Col3)
ID-Unique Column.
I want to move col2 from A to B.
Hence I have added a new column in table B, say col4.
I want an update statement that will transfer A.col2 to B.Col4.
<div class="ForumSig">Regards,
Arun Kumar.A</div>
|
|
|
|
|
Update B <br />
Set Col4 = A.COL2<br />
FROM B<br />
Inner Join A on A.ID = B.ID
Or
UPDATE B<br />
SET COL4 = (Select COL2 From A Where A.ID = B.ID)
Wout Louwers
|
|
|
|
|
It is working.
Thank U very much.
Regards,
Arun Kumar.A
|
|
|
|
|
hi all,
I am not well versed with queries in SQL.
i have a table , product as following
productID productname CategoryID
1 xxx NULL
2 yyy 1
3 zzz NULL
and in the categories table
categoryID categoryname
1 Cat01
2 Cat02
i need to combine these two tables and get the following
productID productname categoryname
1 xxx NULL
2 yyy Cat01
3 zzz NULL
i wrote this query
select c.categoryname,p.productid as pid,p.productname
from product p,categories c
where p.categoryid = c.categoryid
or p.categoryid<>c.categoryid
and this is the result i get
productID productname categoryname
1 xxx Cat01
1 xxx Cat02
2 yyy Cat01
3 zzz Cat01
3 zzz Cat02
Can anyone help me with this query?
Thanks in advance
Regards
Anuradha
|
|
|
|
|
select p.productid, p.productname, c.categoryname<br />
from product p<br />
Left join categories c on p.categoryid = c.categoryid
Wout Louwers
|
|
|
|
|
Hi,
Really thanks for your reply.The query which you gave works perfectly.But now my requirement is
I have a table , product as following
productID productname CategoryID companyId
1 xxx NULL 1
2 yyy 1 2
3 zzz NULL 1
and in the categories table
categoryID categoryname
1 Cat01
2 Cat02
Company Details
CompanyId CompanyName
1 ABC
2 CCC
i need to combine these two tables and get the following
productID productname categoryname companyname
1 xxx NULL ABC
2 yyy Cat01 CCC
3 zzz NULL ABC
how can i write a query for this?
Please help me
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
I think you should be able to solve this yourseld with the help of my first answer...
Wout Louwers
|
|
|
|
|
hi wout,
Thanks very much for your help.I sorted out the query.Its working now.
i am posting the query if anybody needs it in future.
select p.product_service_id, p.product_name,p.tvc_duration,
p.format_type,p.total_fees,c.category_name,m.company_name
from product_service p
Left join company_details m on p.company_id=m.company_id
Left join categories c on p.category_id = c.category_id
Thanks once again
Regards
Anuradha
|
|
|
|
|
I NEED TO UPDATE THESES RECORDS BASED ON THIS QUERY
select * from property where
Lis_key in(select lis_key from property where substring(func_key,1,5)='GEOSS'
And substring(func_key,6,8) >=3)and
Func_key = 'PV000000'
and substring(Attrib_code,5,2)!=16
AND ACTIVE = 1
order by Lis_key
HELP ME
Vuyiswa
|
|
|
|
|
DON'T SHOUT
Just use
update <tablename> set <columnname> = value, ...<br />
Where...
Wout Louwers
|
|
|
|
|
Please tell me sql queery which returns the recordset between two date inclusive of two dates
|
|
|
|
|
"select * from from table where coldate between date1 and date2"
date1 and date2 should be according to database format.
Regards
Shajeel
|
|
|
|
|
I always avoid BETWEEN because it is not clear whether it is inclusive or exclusive. If there was a bug that another developer had to fix I'd want to keep the intent as clear as possible.
|
|
|
|
|
I will keep this in mind. thanks.
Regards
Shajeel
|
|
|
|
|
sonia_basangar wrote: Please tell me sql queery which returns the recordset between two date inclusive of two dates
You have not provided enough information to do that. However, I can tell you that in your WHERE clause you will need something that looks like this:
MyDateColumn >= @SomeStartDate AND MyDateColumn <= @SomeEndDate
Remember that for the end date, you may have to set the time element to 23:59 if you are storing a date and time and want the results for any time on the end date.
|
|
|
|
|
Hi Thanks for reply
MyDateColumn >= @SomeStartDate AND MyDateColumn <= @SomeEndDate
this is perfect this is waht i did but when @SomeStartDate and @SomeEndDate
are same then it dont return the records for same date not works.
|
|
|
|
|
If the start and end date are the same and nothing is returned then there is no data for that date.
Keep in mind what I said about time shifting the end date to 23:59 in case the dates stored in the database contain time information also.
e.g. You want to find stuff on 25/Apr/2007. If you create a datetime with only the date part, the time part will be 00:00 (midnight). If you have data marked as 25/Apr/2007 09:36 then the query will not return anything because the data is not at midnight. This is why you have to set your end date to 25/Apr/2007 23:59 to ensure that you get everything
|
|
|
|
|
Hi Colin
Thanks for your mail
but still my problem is not get resolved
...........
MyDateColumn >= @SomeStartDate AND MyDateColumn <= @SomeEndDate
this is perfect this is what i did but when @SomeStartDate and @SomeEndDate
are same then it dont return the records .
|
|
|
|
|
What Mr.Colin is said right.
He says that some of Ur date Column will have date like 03:03:2007:20:20:20
i.e with hrs and minutes.
Try This:
floor(Cast(MyDateColumn as float)) >=
floor(cast(@SomeStartDate as float)) AND
floor(cast(MyDateColumn as float)) <=
floor(cast( @SomeEndDate as float))
Regards,
Arun Kumar.A
|
|
|
|
|
try like this
MyDateColumn >= "01-Apr-2007 12:00:00 AM" AND MyDateColumn <= "01-Apr-2007 11:59:59 PM"
Make sure urself - the value i gave in double quotes for just sample. So u have to convert this into date in the SQL
Regards
R.Arockiapathinathan
|
|
|
|
|
I need to Find All the Records that Are GEOSS and that are not DUETt.The Following statement made that Possible.
select * from property
where substring(func_key,1,5) = 'GEOSS' And substring(func_key,6,8)>= 3
*There is a Column that is named lis_key in the above results i need to select it from the results above results distictively and search based on that Distict lis_key to Find al records that have
Func_key column ='PV000000' and substring(Attrib_code,5,2)!=16
Please Help ,i hope i explained it clear today
Vuyiswa
Vuyiswa
|
|
|
|
|
REPLYING TO PROBLEM, I GOT IT FIXED NOW THATNKS FROM MY MAN HERE WHO HELPED ME
HERE WAS THE SOLUTION
select * from property where
Lis_key in(select lis_key from property where substring(func_key,1,5)='GEOSS'
And substring(func_key,6,8) >=3)and
Func_key = 'PV000000'
and substring(Attrib_code,5,2)!=16
AND ACTIVE = 1
order by Lis_key
Vuyiswa
|
|
|
|
|
Hi all,
Any one can provide me a way to download/buy "informix ODBC 3.81"
thanks
|
|
|
|
|
Try IBM Informix[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|