Updating a table using a scalar subselect dating notes from my future self


05-Jun-2016 04:48

I can just use the mysql_affected_rows() after that query to see if everything went fine.

The value in table1.field1 can be any valid field type.

Here's simple insert query I came up with that serves 3 functions in my PHP applications:1.) retrieves data from the select query2.) Inserts that row into another table (for record keeping purposes such as purchase orders from shopping carts)3.) validates the input (using mysql_affected_rows()) and will return 0 if the select failed and will not insert at all.

INSERT INTO table2 (field1, field2, field3, field4) (SELECT 'value1 from user input', field1, field2, field3 from table1)The 4 fields in table2 will be populated by the 4 fields (including the string) returned by the SELECT sub-query respectively.

PDF (US Ltr) - 35.6Mb PDF (A4) - 35.6Mb PDF (RPM) - 34.7Mb EPUB - 8.7Mb HTML Download (TGZ) - 8.5Mb HTML Download (Zip) - 8.5Mb HTML Download (RPM) - 7.3Mb Eclipse Doc Plugin (TGZ) - 9.3Mb Eclipse Doc Plugin (Zip) - 11.4Mb Man Pages (TGZ) - 202.4Kb Man Pages (Zip) - 307.8Kb Info (Gzip) - 3.3Mb Info (Zip) - 3.3Mb My SQL Backup and Recovery My SQL Globalization My SQL Information Schema My SQL Installation Guide My SQL and Linux/Unix My SQL and OS X My SQL Partitioning My SQL Performance Schema My SQL Replication Using the My SQL Yum Repository My SQL Restrictions and Limitations Security in My SQL My SQL and Solaris Building My SQL from Source Starting and Stopping My SQL My SQL Tutorial My SQL and Windows My SQL Cluster NDB 7.5 statement within another statement.

All subquery forms and operations that the SQL standard requires are supported, as well as a few features that are My SQL-specific.



were financially independent, or had any options in their home countries, they would not even give you the time of day.… continue reading »


Read more

Famous on social media specifically, because are you even a real person if you're not taking the selfies to prove it?… continue reading »


Read more

Website templates are pre-designed websites, all you need to do is add your own personal content and you're ready to jump start your own website!… continue reading »


Read more

Taking advantage of your power to choose is important, as it allows you to find a supply plan that works with you.… continue reading »


Read more