1

SQL查询:

INSERT INTO probid_users 
(username, password, email, reg_date, payment_mode, balance, max_credit, salt, tax_account_type, tax_company_name, tax_reg_number, tax_apply_exempt, name, address, city, country, state, zip_code, phone, birthdate, birthdate_year, newsletter, pg_paypal_email, pg_worldpay_id, pg_checkout_id, pg_nochex_email, pg_ikobo_username, pg_ikobo_password, pg_protx_username, pg_protx_password, pg_authnet_username, pg_authnet_password, pg_mb_email, pg_paymate_merchant_id, pg_gc_merchant_id, pg_gc_merchant_key, pg_amazon_access_key, pg_amazon_secret_key, pg_alertpay_id, pg_alertpay_securitycode, pg_gunpal_id, first_name, last_name, pg_account_number, pg_account_holder_name, pg_account_holders_number, pg_bank_name, pg_bank_code, pg_paypal_percent_fee, pg_paypal_flat_fee ) 
VALUES 
('42685', '**181e6bd87b116b270bef7c308fd2afdb**', 'jose_jamo@hotmail.com', **1368979346**, **2**, '-5', '5.00', 'dc1', '0', '', '', '0', 'vv fvf', 'fvfvf', 'fvfv', '2083', '2173', '4262', '28823625', '1986-01-01', '1986', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'vv', 'fvf', '', '','', '', '')

错误在哪里?介于????* ?

4

3 回答 3

1

您的列数与您的值数不匹配。

为了防止将来发生这种情况:

如果有可能没有值(查询中可能所有带有空字符串 '' 的字段),您应该添加某个列可以是的选项NULL

CREATE TABLE tbl(
    field1 int NULL /* INSTEAD OF NOT NULL */
)

Null 表示您还不知道该值或没有值。然后你就可以执行这样的语句:

INSERT INTO probid_users 
(username, password, email, reg_date, payment_mode, balance, max_credit, salt, tax_account_type, tax_apply_exempt, name, address, city, country, state, zip_code, phone, birthdate, birthdate_year, newsletter, pg_paypal_email, pg_account_number, pg_account_holder_name) 
VALUES 
('42685', '**181e6bd87b116b270bef7c308fd2afdb**', 'jose_jamo@hotmail.com', **1368979346**, **2**, '-5', '5.00', 'dc1', '0', '', '', '0', 'vv fvf', 'fvfvf', 'fvfv', '2083', '2173', '4262', '28823625', '1986-01-01', '1986', 'vv', 'fvf')

如果您只插入可用值而不是所有值,则可以防止将来出现此类错误。

顺便说一句:您还应该看看数据库规范化(https://en.wikipedia.org/wiki/Database_normalization

于 2013-05-19T17:37:13.867 回答
1

您查询的“INSERT INTO”部分指定了 50 列,但您的“VALUES”仅指定了 48 列。您可以再添加两个空白字符串值以使其均匀。

INSERT INTO probid_users (username, password, email, reg_date, payment_mode, balance, max_credit, salt, tax_account_type, tax_company_name, tax_reg_number, tax_apply_exempt, name, address, city, country, state, zip_code, phone, birthdate, birthdate_year, newsletter, pg_paypal_email, pg_worldpay_id, pg_checkout_id, pg_nochex_email, pg_ikobo_username, pg_ikobo_password, pg_protx_username, pg_protx_password, pg_authnet_username, pg_authnet_password, pg_mb_email, pg_paymate_merchant_id, pg_gc_merchant_id, pg_gc_merchant_key, pg_amazon_access_key, pg_amazon_secret_key, pg_alertpay_id, pg_alertpay_securitycode, pg_gunpal_id, first_name, last_name, pg_account_number, pg_account_holder_name, pg_account_holders_number, pg_bank_name, pg_bank_code, pg_paypal_percent_fee, pg_paypal_flat_fee ) 
VALUES ('42685', '181e6bd87b116b270bef7c308fd2afdb', 'jose_jamo@hotmail.com', 1368979346, 2, '-5', '5.00', 'dc1', '0', '', '', '0', 'vv fvf', 'fvfvf', 'fvfv', '2083', '2173', '4262', '28823625', '1986-01-01', '1986', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'vv', 'fvf', '', '','', '', '', '', '')
于 2013-05-19T17:28:34.903 回答
1

我不会计算所有这些字段以确保它们是,但问题可能是 SQL 中的 '' 是一种逃避 '. 不要将 '' 用于空字符串,请尝试 \'\' 或 '''' 。令人困惑,我知道。

于 2013-05-19T17:30:46.727 回答