mysql

Prohibit MySQL from using full table scan on a query

Is there any way I can prohibit MySQL from performing a full table scan when the result was not found using indexes? For example this query: SELECT * FROM a WHERE (X BETWEEN a.B AND a.C) ORDER BY a.B DESC LIMIT 1; Is only efficient if X satisfies the condition and there is at least 1 row returned, but if the condition cannot be sat...

Why am I receiving an unexpected T_CONSTANT_ENCAPSED_STRING error?

I am getting this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\vacation_showcase\admin\participants_edit_list.php on line 17 This is my sql statement: $sql = 'SELECT substring_index(description,' ',100) as preview, name, extra_line, link FROM participants ORDER BY name ASC'; I dont know why...

MySql: Top 2 records from each ID

I need to get top 2 records of each id from table: SELECT distinct table1.userid AS `Foruser`, (Select table2.Firstname from table2 where table2.table2id = table1.userid ) as 'USERName', (Select table2.email from table2 where table2.table2id = table1.userid ) as 'USERMail', (Select table2.gender from...

Python's MySqlDB not getting updated row

I have a script that waits until some row in a db is updated: con=MySQLdb.connect(server,user,pwd,db) when the script starts the row's value is "running", and it waits for the value to become "finished" while(True): sql='''select value from table where some_condition''' cur=self.getCursor() cur.execute(sql) ...

[PHP/MySQL]: Is there a way to store text in Rich Text Format in MySQL table?

I have given en Entry Form to the user to input values that are stored in a MySQL table. There is one column called "Project Details", wherein the user can input upto 200 characters and this column is of type "varchar". Till here everything is fine. The problem starts when the project details contain a number of points that are to be li...

substring in MySQL

I am trying to insert a string in MySQL table. But the following is not what I am looking for. select substring_index('3|5|6|asdf asd|6|0|NULL', '|', 1) as first, substring_index('3|5|6|asdf asd|6|0|NULL', '|', 2) as second, substring_index('3|5|6|asdf asd|6|0|NULL', '|', 3) as third, substring_index('3|5|6|asdf asd|6|0|NULL', '|', 4) a...

mySQL to postgreSQL

We are trying to switch our application from talking to mySQL to postgres. I wished we would have some kind of a subroutine (in VB6) were I can input the mySQl SQL query and get a string out containing the appropriate postgres query. Does anybody have a solution or is interested working with us on that? Thank you! Thomas ...

mysql remote management

I want to use MySQL Administrator and MySQL Query Browser on a remote mysql server. Should I just change the bind-address to 0.0.0.0 to accept all connections or is there a more secure way. Thanks ...

MySQL not using indexes

Hi, I just enabled the slow-log (+not using indexes) and I'm getting hundreds of entries for the same kind of query (only user changes) SELECT id , name FROM `all` WHERE id NOT IN(SELECT id FROM `picks` WHERE user=999) ORDER BY name ASC; EXPLAIN gives: +----+--------------------+-----...

Python Tornado Web - AttributeError: 'Connection' object has no attribute '_execute'

I'm experiencing a strange behaviour working with the latest branch of tornadoweb when I deploy my app on my production server. I tested several times the code and it is fully working when I test it on my laptop (Archlinux) with python 2.6.3 and MySQLdb 1.2.3b2. As soon as I deploy on my production server (Ubuntu x64) with python 2.6.2...

LOAD DATA LOCAL, How do I skip the first line?

I'm trying to Load a CSV file into my MySQL database, But I would like to skip the first line. I fact It contains the name of my columns and no interesting data. Here is the query I'm using: LOAD DATA LOCAL INFILE '/myfile.csv' INTO TABLE tableName FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERM...

How to display a side nav menu with many sub-categories using PHP and MySQL?

Okay I was wondering how can you use PHP and MySQL to create and display a side nav menu with many categories and sub-categories? I just don't know where to begin coding the PHP code? <ul> <li><a href="" title="">First Nested Link</a></li> <li><a href="" title="">First Nested Link</a></li> <li><a href="" title="">First Nested ...

PHP Registration Form - SQL

Hey all, I want to make a Registration form from PHP to register their username and password into my SQL Database. Here is what I have: config.php: <?php $host['naam'] = 'localhost'; // my host $host['gebruikersnaam'] = 'root'; // my database username $host['wachtwoord'] = ''; // my database password $host['d...

MYSQL, using unique table names VS using ids

Hello, I currently have 26 tables in a MYSQL database. My boss wants me to recreate those 26 tables whenever we have a new client, and append a client abbreviation of some sort to those new tables. So for example there's company1~system~users and company2~system~users and so on and so forth. I'd rather just add a table to the database ...

Python zlib output, how to recover out of mysql utf-8 table?

In python, I compressed a string using zlib, and then inserted it into a mysql column that is of type blob, using the utf-8 encoding. The string comes back as utf-8, but it's not clear how to get it back into a format where I can decompress it. Here is some pseduo-output: valueInserted = zlib.compress('a') = 'x\x9cK\x04\x00\x00b\x00b' ...

mySQL - One large query vs Ajax indivdual queries

Hi guys, I guess no one will have a definative answer to this but considered predictions would be appriciated. I am in the process of developing a mySQL database for a web application and my question is: Is it more efficient to make a single query that returns a single row using AJAX or To request 100 - 700 rows when the user will l...

Is querying for primary keys really worth it?

Jeff Atwood wrote once he found quering database for primary keys, and then getting all relevant fields with an IN clause is double as quick as its single-sql counterpart. I wonder if this applies to all situations, and if not, what are the cases when it still provides significant room for improvement in terms of performance? Furthermo...

How to implement Pagination?

What is the best way to implement simple pagination? Here is the code im using to put the items from the database into a table: $sql = "SELECT * FROM table WHERE id='id' "; $result = mysql_query($sql); while($row=mysql_fetch_array($result))} echo($row['id']); echo($row['name']); } I just wanted to pageinate this so i would u...

What's the different between ` and ' in programming, such as MySQL and shells

phpMySQL use backticks ` to surround column names, and I've just see people use backticks in shell scripts. Is that the same if they use ' ? ...

MySQL.data config File - Visual Basic 2008

Hello I use mysql.data in my visual basic 2008 project. When I build my app and look into the RELEASE folder, I need the .exe.config file to run my app orless it would not work. How would I incorporate this into my application so that I don't need it when I debug my app? Thanks, Kevin ...