Welcome To Snipplr
Everyone's Recent MySQL Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
Create a new database and its respective user with all privileges
0
710
posted 12 years ago by claudiodev
How to remap a value to another inside a mysql query select.
0
1101
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
1019
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
864
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
646
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
750
posted 12 years ago by TheNullByte
Create a new table from the details of another table then insert the table contents
0
732
posted 12 years ago by imbraz
xxxx1... are tables from master site
xxxx2... are tables from client site
0
663
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
1074
posted 12 years ago by klovera
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
976
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
845
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
1394
posted 13 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
794
posted 13 years ago by jpkunst
<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
998
posted 13 years ago by nedf23
Get all page names and ids from the DB of pages with content containing '#'
0
789
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
721
posted 13 years ago by alberomo