|
Don't worry about it, and I must apologise about my rambling response last night - that's what happens when you answer emails immediately after putting the kids to bed.
Seriously though, I honestly don't mind if you disagree with me or not. If I can answer your questions then I will, and as I stated earlier, if I think there's room for a little personal journey there, I will post a hint. If the hint takes you nowhere, I'm always available for clarifications - that's the beauty about being the boss, I get to set my priorities .
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
select p.pid,pd.pid_pm,min(pd.price),p.remarks from p,pd
where p.pid *=pd.pid_pm group by pd.pid_pm,p.remarks,p.pid
i hope so this solve your problem
|
|
|
|
|
Hi folks,
Can anybody suggest me the script by which I can update/insert to a database in remote server without using linked server techniques.
|
|
|
|
|
Yup - if you're using SQL Server, then you need to run a DTS package to update the remote computer. Take a look at Books Online for examples of how to do this.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All,
I want to select all fields without duplication of records. Please help me.
Jegastar
|
|
|
|
|
jegastar wrote: I want to select all fields without duplication of records
SELECT * FROM MyTable
This will return exactly one instance of each row in the named table. However, if two rows have the exact same column values then you will get two rows back that look the same. Stricktly speaking if this happens then data model is likely wrong because all rows should be distinct.
SELECT DISTINCT * FROM MyTable
This will ensure that if two rows share the same information that only one of them will be returned.
|
|
|
|
|
|
hi i got problem with my sql syntax for updating table because i always got query failed <wrong syntax="">
$firstname& $lastname is the variable that user will fill it to change the old lastname to new lastname
"update friends set lastname = $lastname where firstname = $firstname"
plz help me thanks
|
|
|
|
|
Hi,
"update friends set lastname = '" + lastname + "' where firstname = '" + firstname +"'"
use this.
hope this works
Nitin...
|
|
|
|
|
hi nitin, thanks for your help but it cause another error
Parse error: parse error, unexpected T_VARIABLE in
do u know how to fix it
|
|
|
|
|
use "@" instead of "$"
it will work.
|
|
|
|
|
No! NO! NO! NO! NO! NO! NO! NO! NO! NO! NO!
Damn IT! This "solution" compromises the security of the application by making it vulnerable to a SQL Injection Attack.
Please learn how to interact with a database properly. Read SQL Injection Attacks and Tips on How to Prevent Them[^].
|
|
|
|
|
|
Colin Angus Mackay wrote: Damn IT! This "solution" compromises the security of the application by making it vulnerable to a SQL Injection Attack.
I agree, and as usual, people need to look at your article
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
|
I'm hoping someone can help me with this query that I've been struggling with. I'll use an example to explain my problem.
Let's say I have a table named Orders with the following three fields:
CustID, OrderDescr and OrderDate
Now I want to select from this table the first order (oldest date) for each customer. In other words I want a resulting table that lists one entry for every unique CustID in Orders that shows the oldest order for that CustID.
I was hoping the following SQL query would do the trick but it doesn't.
SELECT * FROM Orders O1 WHERE exists<br />
(SELECT TOP 1 * from Orders O2 WHERE O1.CustID = O2.CustID AND O1.OrderDate = O2.OrderDate Order by OrderDate)
Alternatively I was thinking that doing an INNER JOIN with the table on itself there might be a way but I have as yet not been able to figure it out.
|
|
|
|
|
If you're looking for the oldest date, remove the check for O1.OrderDate = O2.OrderDate and use a having min clause.
|
|
|
|
|
OK, sorry for being the klutz here but could you be a little bit more specific please?
I am familiar with the MIN() function as in SELECT MIN(OrderDate) FROM Orders but I'm not sure how to use it with the HAVING clause.
|
|
|
|
|
If the explanation was not clear, you need to learn how to use agregates in sql statement clauses.
|
|
|
|
|
edboe wrote: If the explanation was not clear, you need to learn how to use agregates in sql statement clauses.
So sorry for wasting your time. I'm sure the explanation was clear and I know that I need to learn how to use aggregates in sql statement clauses - which is exactly why I came here.
My apologies again if I asked for too much help. Here's hoping that someone else might be a little bit more forgiving.
|
|
|
|
|
Have you looked up the HAVING clause and realized how easy it actually is?
|
|
|
|
|
You could always do this:
select o1.* from orders o1<br />
where o1.orderdate = (select<br />
o2.orderdate from orders o2<br />
where o1.custid = o2.custid)
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
The only tricky part is getting the OrderDescr field into your result. There are a few ways to accomplish this and I have one listed below (TSQL) that should work. Life would be easier if you had a primary key on the order table.
SELECT
*
FROM
Orders o1
INNER JOIN
(SELECT
custID,
MIN(OrderDate)
FROM
Orders
GROUP BY
custId) o2
ON (o1.CustId = o2.CustId AND
o1.OrderDate = o2.OrderDate)
|
|
|
|
|
Hi everybody,
I hava a table like this:
Table Name- TmpTbl
id PD_Id Remark
1 1 Good
2 2 Bad
3 2 fair
4 3 Bad
5 3 Good
In this i want the select query for the result like this:
id PD_Id Remark
1 1 Good
2 2 Bad
4 3 Bad
Can you help me?
Regards,
Jegastar D.
|
|
|
|
|
In your example, just select where id = 1, 2 or 4.
If you are looking for more complex behaviour, then you need to specify what it is that you are looking for, as we can't divine it from your example.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|