mysql

MySQL: Join two tables with different number of rows and one same column name

Hi, i have two tables "*TABLE_A*" and "*TABLE_B*", and i want to connect them the same way like in "*RESULT_TABLE*". TABLE_A: +-----------+-----------+---------+ | row_id | category | val_1 | +-----------+-----------+---------+ | 1067 | cat1 | 6.5 | | 2666 | test | 6.5 | | 2710 | cat1 | 2.1...

MySQL - large query vs Short query with multiple if's

This is a really broad question, but I have come across it a couple of times in the last few weeks and I was wondering what the general consensus is regarding good practice and efficiency. 1) SELECT COUNT(*) FROM table WHERE id='$id', name='$name', owner='$owner_id' and then based on if there is one result then the record matches. 2)...

Weird MySQL Python mod_wsgi Can't connect to MySQL server on 'localhost' (49) problem

There have been similar questions on StackOverflow about this, but I haven't found quite the same situation. This is on a OS X Leopard machine using MySQL Some starting information: MySQL Server version 5.1.30 Apache/2.2.13 (Unix) Python 2.5.1 mod_wsgi 3 mysqladmin also has skip-networking listed as OFF I am able to connect to m...

MySQL.Data: "Object reference not set to an instance of an object" when trying to Connect.

I have a "Cron Service" that i've had running on our production server for over a year and a half. It's a regular windows service which every minute connects to the DB, checks on one table whether there's something to do, and if so, does it. This is a server for a website that's not used a lot, so most of the time the service is complet...

Which is faster: multiple single INSERTs or one multiple-row INSERT?

I am trying to optimize one part of my code that inserts data into MySQL. Should I chain INSERTs to make one huge multiple-row INSERT or are multiple separate INSERTs faster? ...

Ratings Query Structure and Process Economy

Hi All, I am trying to display overall ratings on the front of my site and although my site and DB are small now, I think this query and process might bog things down when this table gets large. Right now, I have ratings employed that are easy because my query is saying: find all records for this ID, pull all ratings and average them. ...

Help with MySQL Query

Hello. I have two tables in my database, and I would like to retreive information from both of them without having to do two queries. Basically, the user_ID(s) retreived from the tasks table needs to be used to get those respective user(s) names from the users table. This is what I have so far, but the query is returning false: SELEC...

MySQL Query Browser Multiple Statements

So, I'm using MySQL Query Browser to connect to a remote mysql server and trying to execute multiple statements. But it appears to only execute one statement at a time. For instance, it looks like the query browser is only executing a highlighted line and none of the other statements. Is there any way to execute all the statements in a t...

How do I increase Relevance value in an advanced MySQL query?

I've got a MySQL query similar to the following: SELECT *, MATCH (`Description`) AGAINST ('+ipod +touch ' IN BOOLEAN MODE) * 8 + MATCH(`Description`) AGAINST ('ipod touch' IN BOOLEAN MODE) AS Relevance FROM products WHERE ( MATCH (`Description`) AGAINST ('+ipod +touch' IN BOOLEAN MODE) OR MATCH(`LongDescription`) AGAINST ('+ipod +touch'...

What DB extension PHP has (mysqli, PDO etc) is the best for enterprise level application?

What DB extension PHP has (mysqli, PDO etc) is the best for enterprise level application? The important features that comes to my mind are: under active maintenance A lot of documentation and examples. Probably endorsed by the Mysql people themselves. Robust scalable ...

How to make uniques in Django Models? And also index a column in Django.

This is my simple Django database model. It's for a 5-star rating system. class Rating(models.Model): content = models.OneToOneField(Content, primary_key=True) ip = models.CharField(max_length=200, blank=True) rating = models.IntegerField(default=0) As you can see, it is linked to "Content", which is the table for my docu...

What is a good db schema and method to query a "Facebook Wall" feature

I'm writing a simple "Facebook Wall" type feature where a user can post on another person's wall and people can simply reply to that Wall post, or post a new wall post. Users cannot reply to a reply, you may only reply to the original wall post (just like facebook) My original mySQL db schema that I had thought of goes like this: pos...

Big tables and analysis in MySql

For my startup, I track everything myself rather than rely on google analytics. This is nice because I can actually have ips and user ids and everything. This worked well until my tracking table rose about 2 million rows. The table is called acts, and records: ip url note account_id ...where available. Now, trying to do something ...

Asynchronous waiting while C# function is executing

I have a blocking function that executes an asynchronous MySQL query and returns the result when it is obtained. The reason is is asynchronous is this program is not allowed to lock up during a query. The function is called when the user presses a button, so the function may get called several times before the first query completes. I t...

Switching databases in PHP

I'm new to PHP, so this question might best be answered by a brief explanation of fundamentals of PHP rather than addressing what I'm trying to do (although that would be useful too). I want to set up multiple databases for my application, based on user. When the user logs in, it would authenticate them against DB-1, and retrieve from t...

MySQL Extended Display

Is there any equivalent to psql's \x to view a record with each column on a new row? ...

change mysql data directory

Hi All, Is it possible, if I change my default mysql data directory to other. But, will I be able to access the databases from old location. any inputs will be a great help. Thanks in advance Regards, Manasi ...

Can index creation use existing indexes?

I have individual indexes on, say, columns A, B and C. I'd like to create a composite index on the three columns A+B+C. What impact will my existing indexes have on composite index creation? Will the database take advantage of them, are they irrelevant, or will they slow down the creation of my new composite index? I'm using MySql 5.1....

Can I Set The Value Of A Text Input Field Using A Variable?

Hi, I am having one form. I am submitting the values to database of table test fields something .I want to fetch those existing values to text field so that I can edit and update again. I am using below code but I am not getting valid output. Can anyone help thanks in advance. //these values iam passing from one form $bre=$_POST['bf'...

Error in SQL Query Alter Table MySql .

Got an error if I executed below query. ALTER TABLE property_res_details ADD CONSTRAINT PropertyIdLink FOREIGN KEY ( Property_ID ) REFERENCES properties( Property_ID ) ON DELETE CASCADE ; #1005 - Can't create table './resfi/#sql-10e1_8df.frm' (errno: 150) Please Help Me Out. ...