mysql

How did my mysql database get deleted automatically?

Hello, I am very sure that i didn't delete my database and noone else sits on my machine. Then how did i my database get deleted automatically? I had 10 tables in it :(. Infact 2 databases got deleted automatically. They are not being shown in mysql query browser. How can i recover my databases back? Is there any query which will help t...

How much important is it to develop different database specific escaping mechanisms for different projects?

As we know, the magic quotes in PHP is already deprecated, this is done to discourage relying on this feature for preventing SQL Injection and to encourage developers to develop database specific escaping mechanisms.[Source: php.net] Is this really neccessary? If Yes, Why? Why can't we just use functions like mysql_real_escape_string...

Getting first day of the week in MySql using Week No

Hi How do I get the first day of a given week whose week number is available? For example as I write this post we are at WEEK 29.I would like to write a MySQL query that will return Sunday 18 July using this WEEKNO 29 as the only available parameter. ...

Can MySQL (Windows) do SHA-256 and HMAC hashing?

Long time reader, first time poster. And I start with quite a cryptic one! What I'm seeking to do is encrypt a string with the SHA-256 algorithm, and hash it with a key. I discovered someone had done some excellent work in creating an algorithm for "normal" SHA-2 encryption as a stored function at: http://blog.darkrainfall.org/sha-256-...

Generating sets of ids in MySQL

I have a table with some data which I create extracts from: id data1 data2 data3 data4 ----------------------------- 1 foo bar baz foo 2 bar foo foo foo 1 foo doo goo omo An id might have more than one record in that table. Before giving people a copy of the data, I want to replace all identifiers ...

How to select entries from this relationship?

I have these four tables: feeds, feed_entries, entries_categorias and categorias. Whith these structures: CREATE TABLE `categorias` ( `id` int(11) NOT NULL auto_increment, `nome` varchar(100) collate utf8_unicode_ci NOT NULL, `slug` varchar(100) collate utf8_unicode_ci NOT NULL, `principal` int(1) NOT NULL default '0', `ordem`...

mysql field length

How do I find the longest value in my mysql table? I have a php script and I want to search my table to find the record with the longest string? Any ideas? ...

Hibernate with MySQL : Auto-Generate Id : Equivalent of Sequence (Oracle) in MySQL

As far as i Understand, when 'Native' class is used for auto id generation in Oracle, a single hibernate sequence is created, from where all the IDs are supplied to whichever table needed. But i dont see this happen with MySQL. Instead, id's for each table start with 1. Please correct me if am wrong. Also, if i want the same tu happe...

Should I run multiple SELECTs inside a PDO transaction for performance gains?

Are PDO transcations intended just for UPDATE, INSERT and DELETE or can you achieve performance gains if you use a transaction for mulitple SELECT queries? ...

MySQL Join Query

I need to query the database by joining two tables. Here is what I have: Table Town: id name region Table Supplier: id name town_id I currently have the following query which outputs all the Towns that belong to a given region: SELECT id, name FROM Town WHERE region = 'North West'; Now I need to extend this query and create t...

What is the best way to implement a substring search in SQL?

We have a simple SQL problem here. In a varchar column, we wanted to search for a string anywhere in the field. What is the best way to implement this for performance? Obviously an index is not going to help here, any other tricks? We are using MySQL and have about 3 million records. We need to execute many of these queries per second ...

Get SUM in GROUP BY with JOIN using MySQL

I have two tables in MySQL 5.1.38. products +----+------------+-------+------------+ | id | name | price | department | +----+------------+-------+------------+ | 1 | Fire Truck | 15.00 | Toys | | 2 | Bike | 75.00 | Toys | | 3 | T-Shirt | 18.00 | Clothes | | 4 | Skirt | 18.00 | Clothes | | 5 | ...

mysql transactions in asp.net ?

Hi, Can you guys let me know the way of handling transactions in asp.net? i.e. I have a few queries (Present in different functions and called under various situations) that have to be executed as a whole. So, how should I go about it? Not sure of the syntax and the method/practice for writing the statements in .net (commit, rollback ...

Drupal: Cron runs but Autoresponder doesn't send email?

Hi All, Within Drupal I have the Autoresponder module installed. I've configured cron to run twice a day which within the status report it's shown as being run successfully - however no emails are being sent from autoresponder.... If I then run cron manually then the emails are sent? Any ideas very much appreciated. Shane ...

Complex SQL query :: display data inline from multiply tables

Hi i have a proble in finding solution. I have 3 tables: Customer customer_id customer_name Relation subscription_id customer_id Subscriptions One customer can have relation with many subscriptions and i want to display data like so: customer_id, customer_name, subscription_first, subscription_second, subscription_n ...all i...

Is there a sample MySQL database?

Hi, I would like to learn SQL by creating and running queries. However, it does not seem like a great idea to build some bogus data, so, does anyone know a free sample database to download? ...

PHP SQL Pagination Problem

I can't seem to get the desired result. SELECT * FROM `messages` WHERE `msgType` = '0' AND `status` = '0' ORDER BY `dateSent` DESC LIMIT 20, 0 Basically I'm trying to show 20 results per page. But this query returns nothing. (For the record, all instances in the db have msgType and status as 0 EDIT: Removing the L...

Check if string contains another string

Hello, In php is there a way i can check if a string includes a value. Say i had a string "this & that", could i check if that included "this". Thanks UPDATED: $u = username session function myLeagues2($u) { $q = "SELECT * FROM ".TBL_FIXTURES." WHERE `home_user` = '$u' GROUP BY `compname` "; return mysql_query($q, $this->con...

Can't pull out the connection string from the configuration manager

I know I just missing something simple, but when I try pulling the connection string from the ConfigurationManager, I always get null. I have System.configuration added as a reference In the source file I have using System.Configuration; using MySql.Data; using MySql.Data.MySqlClient; .... _connStr = ConfigurationManager.ConnectionStr...

n*n table vs (n^2)*3 table in mysql

A while back I posted a different question regarding column order. While this question does not relate to column order, I was suggested to make my table differently from how I was making it. Lets say I am selling 100 products. Some of these products are compatible with each other, some are not. Some have not been tested yet (I did not m...