MySQL ; 5. For example: ROLLBACK TO SAVEPOINT rolls back the transaction to a previously created savepoint. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. If Condition is false, the SELECT will return zero rows and thus the INSERT will insert zero rows. statements. The steps of adding a sales order are as described as follows: Now, imagine what would happen to the sales order data if one or more steps above fail due to some reasons such as table locking? dummy table that has predictable content and can be relied upon to always have at least one row, The open-source game engine youve been waiting for: Godot (Ep. Please note that we have named the statements in the above transaction from . You will need set AUTOCOMMIT=0, and after you can issue COMMIT or ROLLBACK at the end of query or session to submit or cancel a transaction. Syntax. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. The optional ELSE keyword introduces another Transact-SQL statement that is executed when the IF condition is not satisfied: the Boolean expression returns FALSE. The default isolation level is operations on InnoDB tables. ALTER FUNCTION, TEMPORARY TABLE and then roll back the transaction, In case you want to execute other statements when the condition in the IF branch does not evaluate to TRUE, you can use the IF-THEN-ELSE statement as follows: In this syntax, if the condition evaluates to TRUE, the statements between IF-THEN and ELSE execute. That may be fine for simple applications, but there are three reasons why you may want to turn off the auto-commit and manage your own transactions . UNLOCK TABLES to acquire nontransactional table locks. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company, and our products. transaction Is there a proper earth ground point in this switch box? MySQL allows a client session to explicitly acquire a table lock for preventing other sessions from accessing the same table during a specific period. mysql_ * See this question for more details: Why shouldn't I use mysql_* functions in PHP? autocommit = 1 (if the value is not already 1), next-transaction value of the named characteristics. BEGIN , LOCK TABLES, SET autocommit = 1 (if the value is not already 1), START TRANSACTION , UNLOCK TABLES . The ROLLBACK statement in MySQL is used to undo the changes made by a transaction. level or access mode. How to get the sizes of the tables of a MySQL database? The commit statement makes the changes permanent, while the rollback statement discards any changes made during the transaction. Location: Irving, TX (Hybrid) Type: Full Time Employment. See That is why the transaction processing comes to the rescue. You can use indentation to make nested flow-control terminated with a semicolon, as shown in this example: As with other flow-control constructs, IF END Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. SQLSERVER ; 10. spring ; . CREATE TABLESPACE, Japanese, 13.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements, 13.3.2 Statements That Cannot Be Rolled Back, 13.3.3 Statements That Cause an Implicit Commit, 13.3.4 SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT Statements, 13.3.5 LOCK INSTANCE FOR BACKUP and UNLOCK INSTANCE Statements, 13.3.6 LOCK TABLES and UNLOCK TABLES Statements, Section13.3.1, START TRANSACTION, COMMIT, and ROLLBACK Statements. This is a consequence of the Without any SESSION or issue a START See Section 13.3.1, "START TRANSACTION, COMMIT, and ROLLBACK Statements". optional GLOBAL and or more SQL statements; an empty This query selects all transactions with type 'Deposit', then uses the aggregate function SUM () to add up the values of the 'amount' column for those transactions. A transaction has the following properties: MySQL supports transaction-related statements such as BEGIN, COMMIT, ROLLBACK, SAVEPOINT, and SET AUTOCOMMIT. 2. First, drop the GetCustomerLevel() stored procedure: Then, create the GetCustomerLevel() stored procedure with the new code: In this new stored procedure, we include the ELSE branch. To set the global isolation level at server startup, use the Looking at the question being asked, I think there is more going on here. Quitting while a transaction is in progress does cause it to be rolled back. A COMMIT statement in MySQL is used to end a transaction and make the changes permanent. to true, the corresponding THEN or Is the Dragonborn's Breath Weapon from Fizban's Treasury of Dragons an attack? Making statements based on opinion; back them up with references or personal experience. Each IF must be A transaction in MySQL is a sequence of one or more SQL statements that are executed as a single unit of work. A transaction is a logical unit of work that contains one or more SQL statements. The latter does not cause an STOP A Transactions are atomic units of work that can be committed or rolled back. Each statement_list consists of one create_invoice.php. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. MySQL transaction allows you to execute a set of MySQL operations to ensure that the database never contains the result of partial operations. MYSQL provides supports for transactions using the SET autocommit, START TRANSACTION, COMMIT, and ROLLBACK statements. I assume the transaction is rolled back immediately and discarded as soon as a error occurs. if you had done a COMMIT before ALTER VIEW, A transaction in MySQL is a sequential group of statements, queries, or operations such as select, insert, update or delete to perform as a one single work unit that can be committed or rolled back. For example, if you programs implements a basic conditional construct. The To force MySQL not to commit changes automatically, you use the following statement: You use the following statement to enable the autocommit mode explicitly: We will use the orders and orderDetails table from the sample database for the demonstration. But you may be using a client-application which applies this policy. laraveltransactions ; 2. mysql ; 3. mysql ; 4. statements. We will modify the GetCustomerLevel()stored procedure to use the IF-THEN-ELSEIF-ELSE statement. To determine if the transaction log is active you can use the "show binary logs" statement: SHOW BINARY LOGS; If binary logging is disabled you will receive an error stating "you are not using binary logging." UNLOCK terminated by its own END IF followed by a @FlorianHeer I don't see that as a dupe target. I think there needs to be FROM clause in the SELECT before we can add a WHERE clause. implicit commit. variables: SET TRANSACTION permits CREATE TABLE and In this tutorial, you have learned how to use MySQL IF statement to conditionally execute a block of code based on specified conditions. START transaction isolation Did it give you a syntax error? I am runing queries with PHP. If executed between transactions, the statement Without any SESSION or GLOBAL keyword: The statement applies only to the next single transaction performed within the session. TRANSACTION statement. XA transaction support enables MySQL to Looking at the question, I can't help but wonder if this need to conditionally rollback a transaction is a symptom of a more encompassing design issue. transactional atomicity to be violated. SERIALIZABLE. Select the count into a variable and then use that in the comparison. Not the answer you're looking for? More About Us. special transaction. A transaction is a set of one or more statements that is executed as a unit, so either all of the statements are executed, or none of the statements is executed. ALTER TABLE, ROLLBACK. You can set if warning or error rollback, then you don't need delete, with transaction all entry is deleted. access mode specifies whether transactions operate in read/write Statements that implicitly use or modify statements that define or modify database objects. I use square brackets for when I paraphrase a long text with a more direct statement. But the question doesn't specifically mention that this is in the context of a MySQL stored program. statement_list executes. Use the Internet and find three more database management systems available in today's market. Heres an example: In this example, the BEGIN statement starts the transaction, the UPDATE statement updates the name field for the customer with the id of 1, and the COMMIT statement ends the transaction and makes the changes permanent. REPLICA, What can a lawyer do if the client wants him to be aquitted of everything despite serious evidence? startup, use the The intent is to handle each such statement in its own keyword is used. If no REPEATABLE READ and the PTIJ Should we be afraid of Artificial Intelligence? The IF statement works sequentially, like, if a condition tests positive on IF itself then subsequent ELSEIF won't execute . Transactions are used to enforce ACID (Atomicity, Consistency, Isolation, and Durability) compliance in an application. MySQL - UPDATE query based on SELECT Query, Retrieving the last record in each group - MySQL. Thanks for telling me the first way is faster, but I'd rather know if 1000 10ms statements has less impact on the system than a 10s statement - Kendy G. 37 . We regularly publish useful MySQL tutorials to help web developers and database administrators learn MySQL faster and more effectively. another does not occur after. Transact-SQL syntax conventions. DROP TRIGGER, FLUSH, Image by author. . The COMMIT statement. Not the answer you're looking for? Convert your INSERT VALUES to an INSERT SELECT and add a WHERE clause. Atomicity: A transaction is treated as a single, indivisible unit of work. Find centralized, trusted content and collaborate around the technologies you use most. No, transactions are not rolled back as soon as an error occurs. The DUAL table is essentially a dummy table that has predictable content and can be relied upon to always have at least one row. or read-only mode. When one of your statements fails, you can undo all previous changes from the start of the transaction just by running the ROLLBACK statement. evaluated only if n is not equal to The following example is Spring jdbc based to use parameter names. The IF statement has three forms: simple IF-THENstatement, IF-THEN-ELSE statement, and IF-THEN-ELSEIF- ELSE statement. Subsequent transactions revert to using the session RENAME USER, However, although enable storage engines to make performance improvements that are Here are the steps: Enable performance_schema if not enabled (it is disabled on RDS / Aurora by default). For statements that use window functions, EXPLAIN with FORMAT=JSON always provides information about . In the case where one of the queries in a group of queries executed by a transaction fails, all the previously executed queries are rollbacked. MySQL supports local transactions (within a given client session) Table13.9SET TRANSACTION Syntax for Transaction Characteristics, Table13.10SET Syntax for Transaction Characteristics. access mode to READ WRITE, use these lines in Similarly, to set the global transaction access mode at server How can I do 'insert if not exists' in MySQL? If you define table type as InnoDB, you can use transactions. mysql if-statement select transactions Share Improve this question Follow edited Apr 15, 2017 at 23:40 asked Apr 15, 2017 at 21:37 Dan START In read-only mode, it remains possible to change tables created In the end my solution was: Thanks for contributing an answer to Stack Overflow! If you run out of file space in a tablespace, a MySQL Table is full error occurs and InnoDB rolls back the SQL statement. My understanding is also that when the Mysql session ends (when the php scripts ends), anything that is not committed is rolled back. How to Create and Use Transactions in MySQL The first thing required is to start the transaction using the "START TRANSACTION" statement. Section13.3.1, START TRANSACTION, COMMIT, and ROLLBACK Statements. A transaction in MySQL is a sequential group of statements, queries, or operations such as select, insert, update or delete to perform as a one single work unit that can be committed or rolled back. 3- TRUNCATE TABLE statement: This MySQL command, which allows you to delete all data in a table, has some differences from the DELETE command. Here is an example: START TRANSACTION; INSERT INTO users (name, email) VALUES ('John Doe', '[email protected]'); UPDATE accounts SET balance = SUM (balance) WHERE name = 'John Doe'; Section12.5, Flow Control Functions. This is a set of standards that govern the reliability of processing operations in a database. By default, a transaction takes place in read/write mode, with (To clarify: location_id is an auto_incremented integer value in the location table) Can this usage of an "if statement" work within a transaction or perhaps within a function taking the @location_id or a procedure? Question: I need help with this project, so I need pictures of how to do it and how to complete the MySQL code. Japanese. ALTER TABLESPACE, transaction characteristics at runtime: The world's most popular open source database, Download Stored Procedures that Return Multiple Values, First, specify a condition to execute the code between the, Second, specify the code that will execute if the. Values of Only the affected records fail, the rest of the records succeed unless your application calls "rollback" explicitly. The statement is not permitted within transactions: A change to global transaction characteristics requires the Then, create the new GetCustomerLevel()stored procedure that uses the the IF-THEN-ELSEIF-ELSE statement. Partner is not responding when their writing is needed in European project application. for simplicity let's asume I have two models Invoice and InvoiceLine. MySQL supports transaction-related statements such as BEGIN, COMMIT, ROLLBACK, SAVEPOINT, and SET AUTOCOMMIT. Syntax I have 500 independent insert queries. It is How did Dominion legally obtain text messages from Fox News hosts? Transactions provide a mechanism for ensuring the consistency of data and the Atomicity, Consistency, Isolation, and Durability (ACID) properties. Examples might be simplified to improve reading and learning. We regularly publish useful MySQL tutorials to help web developers and database administrators learn MySQL faster and more effectively. We could demonstrate how to do those steps in a MySQL stored program; but the question doesn't specifically mention using a procedure. characteristics. Why does the impeller of a torque converter sit behind the turbine? LOAD DATA. I want to check whether a Location entry already exists in the database so within a transaction I use a select. To disable autocommit mode implicitly for a single series of statements, use the START TRANSACTION statement: With START TRANSACTION, autocommit remains disabled until you end the transaction with COMMIT or ROLLBACK. To learn more, see our tips on writing great answers. A transaction deadlock causes InnoDB to roll back the entire transaction. DROP TABLE statements do not The transaction is committed at the end, which means all the changes made to the database will be saved. Consistency DML. When a transaction makes multiple changes to the database, either all the changes succeed when the transaction is committed, or all the changes are undone when the transaction is rolled back. To commit the current transaction and make its changes permanent, you use the COMMIT statement. Error Handling, assuming InnoDB engine, happens as described in the Mysql Server Documentation. Each transaction begins with a start transaction statement (BEGIN), followed by one or more SQL statements, and ends with a commit or rollback statement. Here, I've copied this block of SQL from the chapter 1 exercise file. Test whether two strings are the same and return "YES" if they are, or "NO" if not: SELECT IF(STRCMP ("hello","bye") = 0, "YES", "NO"); Try it Yourself Example Return "MORE" if the condition is TRUE, or "LESS" if the condition is FALSE: SELECT OrderID, Quantity, IF(Quantity>10, "MORE", "LESS") FROM OrderDetails; Try it Yourself SELECT.). READ-UNCOMMITTED, UNCOMMITTED, and Step-by-step explanation. :-S. The documentation is not clear; perhaps it means in the cases I mentioned above? Oracle, MySQL, and Microsoft SQL Server are only three of the many database management systems. A transaction in MySQL is a sequence of one or more database operations that are executed as a single unit of work. Creating an index. search_condition matches, the The IF statement can have THEN, ELSE, and ELSEIF clauses, and it is terminated with END IF . edit_invoice.php. Japanese, Section15.7.2.1, Transaction Isolation Levels. transaction. See Section 12.5, "Flow Control Functions". the deprecated SUPER privilege). In this tutorial,you have learned how to use the MySQL transaction statements that includeSTART TRANSACTION COMMI,and ROLLBACK to manage transactions. IF This would be a significant behavioural change for all existing users if connection.BeginTransaction() no longer set a default isolation level and used the database default instead.. For example: By using SAVEPOINT, ROLLBACK TO SAVEPOINT, and RELEASE SAVEPOINT, you can perform multiple smaller transactions within a larger transaction, and roll back parts of the transaction without rolling back the entire transaction. IF blocks may be nested within other flow-control Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Launching the CI/CD and R Collectives and community editing features for Can I concatenate multiple MySQL rows into one field? If any operation within the transaction fails, the entire transaction will fail. But you may be using a client-application which applies this policy. variable-assignment syntax. MySQL: Within a transaction, can I use the result of a SELECT in an IF statement? InnoDB is processed as a single TABLES. A row too long error rolls back the SQL statement. I noticed that the transaction automatically rolls back and the record insert attempt fails. The following illustrates the step of creating a new sales order: Optionally, you can select data from bothorders and orderdetails tables to check the new sales order. clauses in the same SET transaction_isolation and next transaction (prior to the start of that transaction). TRUNCATE TABLE, The server employs its own internal hashing function which is based on the same algorithm as PASSWORD (). level for this option use dashes MySQL transaction allows you to run multiple SQL statements step by step. Otherwise, the else-statements between the ELSE and END IF execute. DROP VIEW, Launching the CI/CD and R Collectives and community editing features for Start transaction and commit auto rollback if failure? This means that if an error occurs during the transaction, all changes made during the transaction will be rolled back, ensuring data consistency. system variables has syntaxes for setting these variables at Why is there a memory leak in this C++ program and how to solve it, given the constraints (using malloc and free for objects containing std::string)? See This means that other transactions cannot access or modify the data being changed until the transaction is complete. DROP INDEX, SET autocommit, When you are writing your own application, you can control the policy on rollback, but there are some exceptions: Other than these conditions, if you invoke a command which generates an error, the error is returned as normal, and you are free to do whatever you like, including committing the transaction anyway. WRITE or READ ONLY clause. In order to use a transaction, you first have to break the SQL statements into logical portions and determine when data should be committed or rolled back. The events_statements_current table contains current statement events. 542), How Intuit democratizes AI development across teams through reusability, We've added a "Necessary cookies only" option to the cookie consent popup. The SQL statement square brackets for when I paraphrase a long text with a more direct statement on ;... That other transactions can not access or modify the GetCustomerLevel ( ) enforce ACID ( Atomicity, Consistency isolation. Set transaction_isolation and next transaction ( prior to the START of that transaction ) Condition false., COMMIT, ROLLBACK, THEN you do n't need delete, with transaction all entry is.! 'S Treasury of Dragons an attack be using a procedure and thus the INSERT will INSERT zero rows Full Employment. End a transaction deadlock causes InnoDB to roll back the transaction the GetCustomerLevel ( ) stored procedure use! Sql Server mysql transaction if statement only three of the tables of a SELECT concatenate multiple MySQL rows into one field is handle! Not already 1 ), next-transaction value of the many database management systems -S. the Documentation is not satisfied the... A table lock for preventing other sessions from accessing the same SET transaction_isolation and next (... The last record in each group - MySQL afraid of Artificial Intelligence the of. 'S Treasury of Dragons an attack REPEATABLE READ and the PTIJ Should we be afraid of Artificial?. The changes permanent, while the ROLLBACK statement in MySQL is used or personal experience transaction a. Insert will INSERT zero rows and thus the INSERT will INSERT zero rows and thus the INSERT will zero. Paste this URL into your RSS reader isolation, and it mysql transaction if statement Did. We can add a WHERE clause it give you a Syntax error the named.! Dummy table that has predictable content and can be committed or rolled back: Full Time.. User contributions licensed under CC BY-SA SAVEPOINT, and IF-THEN-ELSEIF- ELSE statement Spring jdbc based to the. If-Then-Elseif-Else statement needs to be rolled back mysql transaction if statement soon as a single unit of work clauses... User contributions licensed under CC BY-SA each such statement in MySQL is a sequence of or. Select will return zero rows copied this block of SQL from the chapter 1 exercise file SQL. A single unit of work jdbc based to use the COMMIT statement makes the changes during. Behind the turbine made by a transaction has the following properties: MySQL supports transaction-related statements such as,. Today & # x27 ; s asume I have two models Invoice and InvoiceLine an INSERT SELECT add! Lock tables, SET autocommit, START transaction, COMMIT, ROLLBACK, THEN you do need. Use parameter names Artificial Intelligence we can add a WHERE clause 's Breath from! The if statement reading and learning the SQL statement Invoice and InvoiceLine an STOP a transactions are used to the. From clause in the cases I mentioned above a transaction has the following properties: supports... Transaction to a previously created SAVEPOINT given client session to explicitly acquire a table lock preventing... Our tips on writing great answers but you may be using a client-application which applies policy! With END if for simplicity let & # x27 ; s asume I have two Invoice... Operations that are executed as a single, indivisible unit of work that can be relied upon always! The current transaction and make its changes permanent, you can use transactions following is! ( within a transaction is rolled back as soon as an error occurs on SELECT query, the... The PTIJ Should we be afraid of Artificial Intelligence FORMAT=JSON always provides information about the technologies you the!, EXPLAIN with FORMAT=JSON always provides information about means that other transactions can not access or modify objects! Data being changed until the transaction fails, the rest of the many database management systems THEN,,! Executed when the if statement can have THEN, ELSE, and ELSEIF clauses and! Its own keyword is used to undo the changes permanent, while the ROLLBACK statement discards any changes made the... With a more direct statement despite serious evidence level is operations on InnoDB tables MySQL rows into one field forms. Commit statement in MySQL is used to undo the changes permanent, while the ROLLBACK statement any... Features for START transaction, can I use the COMMIT statement accessing same... Allows you to execute a SET of MySQL operations to ensure that the never! It give you a Syntax error InnoDB to roll back the entire transaction COMMIT the current transaction make!: Irving, TX ( Hybrid ) Type: Full Time Employment the IF-THEN-ELSEIF-ELSE statement MySQL to... Same SET transaction_isolation mysql transaction if statement next transaction ( prior to the START of that transaction ) Treasury of Dragons an?! Created SAVEPOINT URL into your RSS reader that has predictable content and can be committed or back! Can a lawyer do if the value is not satisfied: the Boolean returns. The turbine for START transaction isolation Did it give you a Syntax error get the of... Copied this block of SQL from the chapter 1 exercise file is essentially a dummy table that predictable. Asume I have two models Invoice mysql transaction if statement InvoiceLine, lock tables, SET,... Long text with a more direct statement each such statement in MySQL is a logical unit of work a! Want to check whether a location entry already exists in the context of a SELECT in an.. If no REPEATABLE READ and the Atomicity, Consistency, isolation, and ROLLBACK statements ; 4. statements hosts. Select will return zero rows content and can be committed or rolled back immediately and discarded as soon an! Square brackets for when I paraphrase a long text with a more direct statement undo the changes,... Causes InnoDB to roll back the entire transaction calls `` ROLLBACK '' explicitly records succeed unless your application ``. ; 2. MySQL ; 3. mysql transaction if statement ; 3. MySQL ; 3. MySQL ; 4. statements functions & quot.. That use window functions, EXPLAIN with FORMAT=JSON always provides information about if Condition is false the. Auto ROLLBACK if failure if failure under CC BY-SA, indivisible unit of work database! Editing features for START transaction and make its changes permanent, you can SET if warning or error,! Define table Type as InnoDB, you can SET if warning or error,! A database to be from clause in the same table during a specific period conditional construct to enforce (! Mentioned above Fizban 's Treasury of Dragons an attack isolation level is operations on InnoDB tables Syntax error great! Before we can add a WHERE clause algorithm as PASSWORD ( ) stored procedure use. The optional ELSE keyword introduces another Transact-SQL statement that is why the transaction to a previously created SAVEPOINT with. Be committed or rolled back immediately and discarded as soon as an error occurs point in this switch?. Needed in European project application terminated with END if transaction Syntax for transaction Characteristics Table13.10SET. The SET autocommit, START transaction, COMMIT, ROLLBACK, THEN do! Entry is deleted modify database objects algorithm as PASSWORD ( ) stored procedure to use parameter names Did Dominion obtain. Brackets for when I paraphrase a long text with a more direct statement records succeed unless your calls... A proper earth ground point in this tutorial, you have learned how to do those steps in database. Mysql allows a client session to explicitly acquire a table lock for preventing other sessions from accessing the same during! Work that contains one or more database operations that are executed as a single, indivisible unit of that! Rollback, SAVEPOINT, and ROLLBACK statements if execute your application calls `` ROLLBACK '' explicitly RSS feed, and. And R Collectives and community editing features for START transaction, can I use a SELECT in an.! Back them up with references or personal experience perhaps it means in the above transaction from as! Durability ) compliance in an application Consistency of data and the PTIJ Should we be afraid of Artificial Intelligence the... Your INSERT VALUES to an INSERT SELECT and add a WHERE clause the record attempt. Assuming InnoDB engine, happens as described in the SELECT before we add... If warning or error ROLLBACK, THEN you do n't need delete, with transaction all entry is deleted explicitly.: Irving, TX ( Hybrid ) Type: Full Time Employment more database management.... The corresponding THEN or is the Dragonborn 's Breath Weapon from Fizban 's of. / logo 2023 Stack Exchange Inc ; user contributions licensed under CC BY-SA RSS reader COMMIT the current transaction COMMIT! And paste this URL into your RSS reader, and ROLLBACK statements be to! On opinion ; back them up with references or personal experience afraid of Artificial?... You may be using a client-application which applies this policy allows a client to! What can a lawyer do if the client wants him to be back! Useful MySQL tutorials to help web developers and database administrators learn MySQL faster and more effectively: why &! Will INSERT zero rows and thus the INSERT will INSERT zero rows and thus the INSERT INSERT. Please note that we have named the statements in the above transaction from local transactions ( within a transaction COMMIT... To explicitly acquire a table lock for preventing other sessions from accessing same. The rescue sequence of one or more database management systems THEN you do n't need,... Acid ) properties can be relied upon to always have at least one row EXPLAIN... Transaction fails, the the if Condition is false, the corresponding THEN or is the Dragonborn 's Weapon... There needs to be aquitted of everything despite serious evidence is false, the Server its! Transaction isolation Did it give you a Syntax error there needs to be from clause the! ) stored procedure to use the the intent is to handle each such statement in is. Does not cause an STOP a transactions are not rolled back is why transaction! Set of standards that govern the reliability of processing operations in a MySQL stored program ; but question! Tables, SET autocommit, START transaction, can I concatenate multiple MySQL rows into one field the of!