I would lean toward hashing, encrypting, or somehow munging the value in your hidden form field, like you suggested. There are so many ways to do that, you have your pick. That's news to me, that MySQL will store enums in 1 byte. I can imagine how it's possible (
lookup "table" and a 1-byte int yielding 256 values), it's just not an option we have without making a 2nd table in SQL Server, so it stood out to me as something to suggest - but it sounds like you ought to ignore me on this one. In MS, if we use a bit field, 1 of them = 1 byte, but 2 bit fields also = 1 byte, up to 8. So we tend to prefer those when possible, and you and I have been talking deeper level implementation.
Anyway, a correlated subquery is when you have an "outer" and an "inner" query that are correlated. The inner query filters which rows pass through the outer query, and the outer query shapes what the inner query looks like. I don't understand your schema, so I'll make some assumptions that will probably be wrong.
Code:
UPDATE customer_contract As C SET approved='Yes' WHERE customer_website=1 AND customerID In (Select customerID From customer_account A Join customer_website W On A.ID = W.ID)
I don't think that's even close to your intention. A simpler but more abstract example is
Code:
Select * From Order_Header Where Order_Total > (Select Avg(Order_Total) From Order_Header)
That one isn't correlated - there's a 1 way link. The inner subquery will limit what comes out of the outer query, but the outer query doesn't drive what the inner query considers. Actually, that might be a better match than, say, if you changed the query I just posted to only find the average for customers in the same state as that order.
Code:
Select * From Order_Header OH Where Order_Total > (Select Avg(Order_Total) From Order_Header IH Where OH.State = IH.State)
Here's from MSDN
Quote:
Correlated Subqueries
Correlated subqueries involve two queries which are mutually dependent. The values from the "outer" query feed into the "inner" query, which in turn determines the results of the "outer" query. Correlated subqueries have many applications outside of the scope of this page. For more information see the links at the bottom of this page. One (of many) general examples of this query is as follows:
SELECT <Column List>
FROM MyTable AS a
WHERE NOT EXISTS (SELECT Column1
FROM MyOtherTable AS b
WHERE a.KeyColumn = b.KeyColumn)
The following example uses AdventureWorks to demonstrate a correlated subquery:
USE AdventureWorks
GO
SELECT c.CustomerID
FROM Sales.Customer AS c
WHERE NOT EXISTS
( SELECT sh.CustomerID
FROM Sales.SalesOrderHeader AS sh
WHERE c.CustomerID = sh.CustomerID
AND sh.OrderDate BETWEEN '2004-01-01' AND GETDATE())
Caution: Under some circumstances, a correlated subquery can result in poor query performance (the solution is less of a pure set solution than the other examples on this page. As with any query, test each option and analyze the query plans under realistic test circumstances prior to deciding on a strategy.
|