Skip to content

Tag: sql

How to convert last insert id into string?

I have a create account page and on the page I have one button to insert all the details into two seperate tables one of the tables Pictures is dependant on the User table 1:1 relationship via UserID. I have written some code to try get the last insert id so I can insert into the pictures table: Not sure

How to do a batch insert in MySQL

I have 1-many number of records that need to be entered into a table. What is the best way to do this in a query? Should I just make a loop and insert one record per iteration? Or is there a better way? Answer From the MySQL manual INSERT statements that use VALUES syntax can insert multiple rows. To do

Update cell in jTable using SQL

I want to know how I can update specific cells in jTable (in Java) using SQL. This my try but it doesn’t work. Note: I am working in Netbeans. Answer finally I’ve found the correct answer the following code will explain every thing thanks for every one helped me

How to automatically convert a MySQL column to lowercase

Is there a property that I can add to a column so that it converts its value to lowercase? Instead of doing it for every single value through PHP? Answer You could probably do it through a trigger that fires on insert or update. Myself, I’d rather just create a view that has a lower-case version of the …

MySQL OPTIMIZE all tables?

MySQL has an OPTIMIZE TABLE command which can be used to reclaim unused space in a MySQL install. Is there a way (built-in command or common stored procedure) to run this optimization for every table in the database and/or server install, or is this something you’d have to script up yourself? Answer You…

SQL query for today’s date minus two months

I want to select all the records in a table where their date of entry is older then 2 months. Any idea how I can do that? I haven’t tried anything yet but I am on this point: Answer If you are using SQL Server try this: Based on your update it would be: