Welcome To Snipplr


Everyone's Recent MySQL Snippets



How to find a given column in a given database in MySQL
1 918 posted 12 years ago by philsown
Create a new database and its respective user with all privileges
0 691 posted 12 years ago by claudiodev
How to remap a value to another inside a mysql query select.
0 1075 posted 12 years ago by ginoplusio
You could start a transaction before running your queries and then rollback after running them. Note that to do this you'll require InnoDB or XtraDb tables (won't work on MyISAM).
0 993 posted 12 years ago by satie83
You have a schedule table (period, day, subject, room) with a primary key period,day to avoid duplicate bookings. You wish to display the schedule as periods, subjects and rooms in rows, and days of the week in columns.
0 834 posted 12 years ago by cahyadsn
Given a birthdate in @dob, here are two simple formulae for age in years : (the second formulae is for age in years to two decimal places, ignoring day of month)
0 629 posted 12 years ago by cahyadsn
Instead of the standard return of duplicates, this will actually show the rows that are duplicated, making it easier to see the data
0 723 posted 12 years ago by TheNullByte
add created datetime and modified timestamp columns to table
0 626 posted 12 years ago by navblue
Create a new table from the details of another table then insert the table contents
0 710 posted 12 years ago by imbraz
xxxx1... are tables from master site xxxx2... are tables from client site
0 647 posted 12 years ago by A973C
If you have a Table which has a Column of type char or varchar or even text, and you want to change a portion of text in it for example a path. In this case you need to change the same text with new one in every records.
0 1032 posted 12 years ago by klovera
Update an empty name column in default_comments
0 627 posted 12 years ago by jgomez
Example: There is a table, 'user', with a column, 'clear', containing values such as: `clear -------- \'animal\' \'pass'\ ` and we would like to retrieve 'animal' and 'pass' ( without the pre & post \' )
0 957 posted 12 years ago by jgomez
Select wp_users and wp_posts to retrieve data from both tables in order to display post title, post date, author name with gravatar (gravatar isn't listed in this code) Note: probably not idea solution, but it's one of many fixes
0 830 posted 12 years ago by ninacess
Most popular languages on the web table (in order of popularity). Handy for auto complete fields and such.
0 1365 posted 12 years ago by Synnoid
Converts textual dates like '1-3-1954' and '01-02-1963' to respectively '1954-3-1' and '1963-02-01'. MySQL is smart enough to understand the values without leading zeros when inserting into a DATE field.
0 780 posted 12 years ago by jpkunst
0 833 posted 13 years ago by irishsk
<h1>What it does</h1> <p>This snippet is used to pull data from one server to another. I primarily use it to get the latest data from our production to our development environments. The first part of the command is where the data is pulling from a...
1 971 posted 13 years ago by nedf23
Used to update a database field using search replace.
0 779 posted 13 years ago by carouselcreative
0 806 posted 13 years ago by athome
Get all page names and ids from the DB of pages with content containing '#'
0 767 posted 13 years ago by nielsenrc
Instrucciones Mysql para crear un nuevo usuario (añadiendo valores a campos existentes en una BBDD existente) y una nueva BBDD con una tabla con cuatro campos a la que tenga acceso el usuario creado.
0 705 posted 13 years ago by alberomo
0 694 posted 13 years ago by hotdiggity
Simple example of how you can output a query as
0 852 posted 13 years ago by Jamie
0 722 posted 13 years ago by mantosz