I get this error when I try to execute the following select statement:
"All Parts of a PRIMARY KEY must be NOT NULL; if you need null in a key, use UNIQUE
instead."
CREATE TEMPORARY TABLE IF NOT EXISTS
CashVariances
(PRIMARY KEY(sUnit))
SELECT
sUnit,
dSalesDate AS dDate,
SUM(nStoreCash) AS aCash,
SUM(nBankCash) AS bCash,
SUM(nStoreCash) - SUM(nBankCash) AS nDifference
FROM
CashBalances
GROUP by
sUnit,
dDate
ORDER BY
RIGHT(concat('0',sUnit),4),
dDate
I created this statement based on this sample from a book:
CREATE TABLE new_tbl (PRIMARY KEY (a)) SELECT a, b, c FROM old_tbl
The thing is that I want the Field "sUnit" to be the PRIMARY KEY and the recordset
returned by the SELECT Statement does not return NULL values. I can't find any
alternatives except for first creating the table and then inserting the records. If
it's something wrong in my CREATE SELECT statement, please, let me know. Any help
will be really appreciated...
Thanks in advance,
Carlos V�zquez
Jr. Financial Programmer
MySQL 3.23