mysql not enough arguments_Not enough arguments for format string mysql error

When you have a large number of columns, it can be a challenge to make sure you have one %s for each column. There's an alternative syntax for INSERT that makes this easier.

Instead of this:

INSERT INTO ACTIVE_PROPERTIES(Property_ID, Reference_Number,

Address_Name, Address_Number, Address_Street, Address_2, Address_3,

Address_4, Address_Postcode, Owner_Contact_ID, Owner_Name,

Owner_Number_Type_1, Owner_Contact_Number_1, Owner_Number_Type_2,

Owner_Contact_Number_2, Owner_Number_Type_3, Owner_Contact_Number_3,

Owner_Email_Address, Display_Property_Type, Property_Type,

Property_Style, Property_Bedrooms, Property_Bathrooms, Property_Ensuites,

Property_Toilets, Property_Reception_Rooms, Property_Kitchens,

Floor_Area_Sq_Ft, Acres, Rent, Rent_Frequency, Furnished,

Next_Available_Date, Property_Status, Office_Name, Negotiator,

Date_Created)

VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,

%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,

%s, %s, %s, %s, %s)

Try the following, to make it easier to match up columns with %s parameters, so you don't miscount:

INSERT INTO ACTIVE_PROPERTIES

SET Property_ID = %s,

Reference_Number = %s,

Address_Name = %s,

Address_Number = %s,

Address_Street = %s,

Address_2 = %s,

Address_3 = %s,

Address_4 = %s,

Address_Postcode = %s,

Owner_Contact_ID = %s,

Owner_Name = %s,

Owner_Number_Type_1 = %s,

Owner_Contact_Number_1 = %s,

Owner_Number_Type_2 = %s,

Owner_Contact_Number_2 = %s,

Owner_Number_Type_3 = %s,

Owner_Contact_Number_3 = %s,

Owner_Email_Address = %s,

Display_Property_Type = %s,

Property_Type = %s,

Property_Style = %s,

Property_Bedrooms = %s,

Property_Bathrooms = %s,

Property_Ensuites = %s,

Property_Toilets = %s,

Property_Reception_Rooms = %s,

Property_Kitchens = %s,

Floor_Area_Sq_Ft = %s,

Acres = %s,

Rent = %s,

Rent_Frequency = %s,

Furnished = %s,

Next_Available_Date = %s,

Property_Status = %s,

Office_Name = %s,

Negotiator = %s,

Date_Created = %s;

It's not standard SQL, but it's supported by MySQL. It does the same thing internally, it's just more convenient syntax, at least when you're inserting a single row at a time.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值