Monday, 15 March 2010

MySQL UPDATE table 1 and INSERT on table2 if id doesnt exist -


I have a left join query that shows values ​​from the primary table (tblmarkers) and all the fields from another table (tblmarkers) TblLocations) where Milan is the record. There is no record for each ID of tblMarkers in TblLocations

  $ query = "SELECT` tblmarkers`. *,` TblLocation`. *, `TblLocation` .```````` `Tblmarkers' with 'Marker ID' LEFT JOIN` tblLocation` at `TblMarkers` .ID` =` TBLOolation``````` where `TBL markers` id = $ id";   

I am comfortable to use the update to update the tblmarkers field but how do I update or insert a record in TBLocation if the record still does not exist.

Also, how can I record a record to prevent any other person from updating at the same time?

Can I also use Update Tumblr Marker * or do I need to update every field statement? Unfortunately you may have to apply some assumptions to your external script in a in SQL.

If statement, but I'm not sure that you can turn on different commands depending on its result.

Lock

In case of locking, you have 2 options for MyISAM tables, you only

  Lock table users can lock the entire table;   

For InnoDB tables, there is no clear 'lock' for single rows, although you can use the transaction to gain exclusive rights during the operation.

Update

Some may be a hint of short stories, but I think that you must list each field in your query. Alternatively, you can always read the entire line, delete it, and insert the shorthead again via the INSERT query. It all depends on how many fields you have.

No comments:

Post a Comment