mysql

Run Sql file in MYSQL PHPMyadmin

Hi All, I have written the SQL file with on excecuting it is throwing the error as mysql> @"C:\Documents and Settings\Hemant\Desktop\create_tables.sql"; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@"C:\ Documents and Setting...

Best Primary Key for a friendship table.

I have read a number of solutions for a mysql facebook friendship table and have decided on a fairly simple table with two fields user_a and user_b. I would then using a query with a UNION to get a list of all of a users friends (as they could be in user_a or user_b). My question now is... is it better to have a auto incrementing unique ...

Seeding a Rails Database with Pre-set IDs

I have an XML file containing seed data that I'm trying to load into my production database. The problem being that I have associations between different data types / nodes in the XML file, and so I need the specified IDs to be the same when loaded into MySQL from Rails. This works fine with SQLite during development, I just use a line...

The explain tells that the query is awful (it doesn't use a single key) but I'm using LIMIT 1. Is this a problem?

The explain command with the query: explain SELECT * FROM leituras WHERE categorias_id=75 AND textos_id=190304 AND cookie='3f203349ce5ad3c67770ebc882927646' AND endereco_ip='127.0.0.1' LIMIT 1 The result: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE ...

how to set anything in database then he not allow duplicate rows in a table

how to set anything in database then he not allow duplicate rows in a table means name abc name abc means some row sames as each other then i need to take one copy of it and remove each other ...

Is there a way to dump all mysql databases except for system databases?

I use mysqldump to automatically dump all my databases to a text file and save this dump as backup. I use the --all-databases option which dumps my databases, but it also dumps system databases (information_schema, phpmyadmin, etc.) which I don't need. Is there a way to dump all my databases with mysqldump without naming them explicitly...

Rails find :conditions

I have a Reservation model that I'm searching for with three fields. The container_id must always be self.id but as confirmed and auto_confirmed only one needs to be true. I have the following but it doesn't perform what I need: Reservation.find(:all, :conditions => ['container_id = ? AND confirmed = ? OR auto_confirm = ?', self.id, ...

ODBC vs MySQLClient

I'm currently using ODBC to connect to my MySQL database, using C#. I've been told that using the MySql Connector would be better, and faster, and not dependent on Windows. Can someone shed some light on this please? I've been unable to find anything on the net so far ...

DBSlayer - what does it actually do?

I recently stumbled across DBslayer (http://code.nytimes.com/projects/dbslayer/wiki/WhyUseIt) and wondered what is the actual benefit of using it as an interface to mysql. As far as I understand, it runs as some kind of proxy for mysql and offers a HTTP / JSON interface. So? Why should I use this setup instead of connecting directly to...

Query doesn't use a covering-index when applicable

I've downloaded the employees database and executed some queries for benchmarking purposes. Then I noticed that one query didn't use a covering index, although there was a corresponding index that I created earlier. Only when I added a FORCE INDEX clause to the query, it used a covering index. I've uploaded two files, one is the executed...

How to update mysql data when using explode

I have this code to load the month of the birthday that corresponds to the id number: < ?php $query = "SELECT DISTINCT BIRTHDAY FROM student WHERE IDNO='".$_GET['id']."'"; if($result = mysql_query($query)) { if($success = mysql_num_rows($result) > 0) { ?> <select title="- Select Month -" name="mm" id="...

MySQL: How to separate a name field in one table into firstname / lastname in two separate tables?

I have a drupal database where the node table is full of profiles. The field node.title is "Firstname Lastname". I want to separate the names so that node.title = "Firstname", and over in another table entirely, content_type_profile.field_lastname_value = "Lastname". The entries in the two tables can be joined on the field nid. I'd l...

Jdbc Template and MySql interaction for Frequently Changing Queries

There are some queries used by a DAO layer that is implemented in JDBC Template String longQuery = "....."; public List<AnObject> findObjectsBySomething(Something s) { return getJdbcTemplate().queryForObjects(longQuery, myRowMapper, s); } longQuery is going to frequently change, but I don't want to have to manage it right in the s...

a reusable query with modifications?

i'm using this mysql query alongwith php to search for multiple keywords: $query = "SELECT cQuotes, vAuthor, cArabic, vReference FROM ".$table." WHERE ("; $countFields = count($arrayFields); while ($a < $countFields) { while ($b < $countSearch) { $query = $query."$arrayFields[$a] LIKE '%$arraySearch[$b]%'"; $b+...

Codeigniter active record sql error

I am using the get_where() function in codeigniter, and I am getting mysql errors, dependent on what I set the limit and offset too, for example this code, $this->db->get_where('em_user', $whereArr, 30, 0)->num_rows() returns a mysql error that looks like this, Error Number: 1064 You have an error in your SQL syntax...

MySQL - Accessing all relational data in one query

I have a relation mysql database setup. and I want to pull all the data for one item from the main row and all the relational data (ie multiple associated rows) in one query. What's the easiest/best way to do this aside from a multiple JOIN statement in one query? The tables and query currently used are below. Relational data --------...

Drop mysql tables in Rails

How do I drop selected tables in Rails? I want to drop all tables from a database with a given prefix. PHPMyAdmin would be very useful at this point. Thanks ...

MySQL Trigger With SELECT Statement.

Hello, I want to make trigger that having SELECT Statement in it but that SELECT query returns more than one rows so, How can I handle that multiple rows in trigger and looping that rows in MySql? Please Help me. :Jimit ...

How to backup my MySQL's databases on Windows Vista?

Hello. How can I backup my MySQL's databases? I'm using Windows Vista and MySQL 5.1. I have found the folder "C:\Users\All Users\MySQL\MySQL Server 5.1\data" with all my database files and copy them, but how can I restore them if I need? Thank you. ...

Using MySQL in Pydev Eclipse

Hi, I am trying to access a MySQL database with python through Pydev Eclipse. I have installed the necessary files to access MysQL from python and I can access the database only when I write code in Python IDLE environment and run it from command prompt. However I am not able to run my applications from Pydev. when I use this "import M...