|
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.
|
|
|
|
|
Acctuly this is my table
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 following result
id PD_Id Remark
1 1 Good
2 2 Bad
4 3 Bad
|
|
|
|
|
Id, PD_ID, Remark are the 3 fields that i have used in this table.
|
|
|
|
|
There is (almost) nothing consistent or special about your desired result set (no specific visible relationship between the value of remark, id , PD_ID).
The resultset can be produced with
"select top 3 id,pd_Id,remark from table where Remark in ('Good','Bad') order by PD_Id ASC"
But that does not seem particularly useful.
|
|
|
|
|
iam having 10 triggers for a table
i want view the triggers
which trigger is firing
is it possible to know
or any system stored prodeure is avaliable in sqlserver 2000
with regards
|
|
|
|
|
In Enterprise Manager, right click on the table and select Manage Triggers. The listbox at the top allows you to view the different triggers - by default it shows the New trigger option.
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.
|
|
|
|
|
This will give you a list of all triggers on a table:
sp_helptrigger[^]
You might want to look at this too:
Using Nested Triggers[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Hello everyone:
I have a MySQL server running on a linux that is working properly, and i have errors trying to connect to the server on a windows NT client using ODBC. The error i am getting is Can't connect to MySQL 10060. The driver i am using is ODBC 3.51,(i wish to create a vb app using the driver to access the database) I am quite sure that the parameters that i specified for the host name etc are correct. I even downloaded the MySQL control centre to test the connection to the MySQL linux server, but it still doesnt work. I tried using the same ODBC driver and the same windows client to connect to another dummy MySQL server running on a remote windows PC and it works. Also I have a website coded in PHP that can access the MySQL database on any windows pc, so it couldn't possibly be that the MySQL server blocks out my clients IP address right?
Please help Thanks in advance
andy
-- modified at 2:47 Monday 27th November, 2006
|
|
|
|