mysql

MySQL: Is there a way to reset a table?

Is there a way to reset a table? I mean not only deleting all rows, but starting the auto_incrementing ID back to 0? ...

many things in one query. is it possible?

I have three tables menus +--id---ident---+ |--1----menu_1--| menus_data +--id---id_parent---name---------id_lang--+ |--1----1-----------menu_eng------1-------| |--2----1-----------menu_rus------2-------| +--3----1-----------menu_arm------3-------+ languages +--id---name--------+ |--1----english-----| |--2----russian-----| |--3--...

Add remote library in netbeans c++ application

I am writing a c++ application that uses mysql, and I am having a problem with including in my project. I am using netbeans with remote development and I am wondering how do I add the mysql folder (/usr/local/mysql/include/mysql/) into my include path over remote development. I notice that netbeans copies across all standard libraries...

Re-Invent a better wheel or make ado with available RDBMS-based app development products?

My first experience developing DBMS-based apps was with IMS, using COBOL calls to DLI. Later on, I worked with several other products, on a smaller scale, such as: DBASE, INFORMIX 3.3/SQL and ORACLE on DOS, UNIX-XENIX and VAX/VMS platforms. When I was a product planner for AT&T-IS Labs, I had the opportunity to eval several RDBMS-based a...

Is there anything like unique_together(max_occurences=3) ?

I have a model: class MyModel(models.Model): a = models.IntegerField() b = models.IntegerField() c = models.IntegerField() Now, I need something like unique_together(a,b, max_occurences=3) constraint to be added to the above model (so that there can be up to 3 values of c for each pair of (a,b), and ideally those 3 val...

Optimizing Magento-using Websites

Please be patient with my question, as this may be a bit longer. If you look at Magento and try to compare with any other non-PHP eCommerce Shopping Cart websites, you will find that the latter are comparatively faster. I know that the following factors work as well:- Hosting Server Bandwidth Magento offers lots & lots of features, ...

MySql using primary index instead of multiple column one!

Ok so I've a SQL query here: SELECT a.id,... FROM article AS a WHERE a.type=1 AND a.id=3765 ORDER BY a.datetime DESC LIMIT 1 I wanted to get exact article by country and id and created for that index with two columns type and id. Id is also primary key. I used the EXPLAIN keyword to see which index is used and instead of the multiple...

Monitoring DB: MySQL

Hi, I am writing to ask for advice. I have to monitor certain "insert" on a mysql db. In what way is more convenient to do this? The application uses Servlets and MySQL. Thank you very much ...

How to get two rows value

Using mysql I want to display two rows values in to single value ID Name --------- 01 Raja 02 Ravi Expected output: 01Raja 02Ravi How to make a query for this condition? ...

Please will you help tune a 7-table-join mysql count query where tables contain 30,000+ rows?

I have an sql query that counts the number of results for a complex query. The actual select query is very fast when limiting to 20 results, but the count version takes about 4.5 seconds on my current tables after lots of optimizing. If I remove the two joins and where clauses on site tags and gallery tags, the query performs at 1.5 sec...

Get last Inserted 'Id' while doing multiple entry to mysql in codeigniter

In my form, there are values to be inserted to multiple tables. After inserting to the first table, i have to insert the other values, along with the 'id' of the entry to first table as reference. What is the best way to do this? Is there any codeigniter specific way? ...

Search specific wordpress MU tables MySQL

I have a blog built that is grabbing information from another set of tables in the MU Database. I need to now be able to also search that database. Does anyone have that MySQL query needed to make a clean search? ...

MYSQL - Combining Two Results in One Query

I have a query I need to perform to show search results for a project. What needs to happen, I need to sort the results by the "horsesActiveDate" and this applies to all of them except for any ad with the adtypesID=7. Those results are sorted by date but they must always result after all other ads. So I will have all my ads in the res...

ANDing in join condition???

Is it possible to use AND in a join condition? For example: SELECT * FROM items LEFT JOIN products as prod ON prod.prod_id = items.prod_id LEFT JOIN partial as p ON p.prod_model = prod.prod_model AND p.order_id=$order_id WHERE order_id = $order_id ORDER BY prod.prod_weight ASC I am guessin...

MYSQL Update with 2 INNER JOINs hangs

I am trying to update a field in my table based on if it exists in two join tables. update quotes inner join collection_records ON quotes.id <> collection_records.record_id inner join subcollection_records ON quotes.id <> subcollection_records.record_id set quotes.status_id = 1 where collection_records.type = 'Quote' or subcollectio...

Tricky SQL for a smart search

I am using a form through a PHP CMS system, that defines custom fields and such. One of the custom fields allows for an input field which does a smart search. What this means is that when you start typing, it shows the records that match, quite similar to google suggest. The smartsearch input field relies on a stored mysql search, and ...

How can I compare MySQL Versions in PHP?

Okay, so I'm getting my MySQL Version like so: preg_replace('#[^0-9\.]#', '', mysql_get_server_info()); Which gives me a number like: 5.1.36 That's all good. What I need to do, is compare that version with another version. I was about to attempt to write my function to compare them, when I thought of version_compare(). However, upon ...

SQL: How to refactor this multi-table delete statement

Can anyone suggest a cleaner method to delete rows with a one-to-many relationship in one query? This works, but I'm not very familiar with the using clause or delete, so I don't fully understand how it works. DELETE FROM ip_record, entry using ip_record inner join entry where ip_record.site_id = ? ...

capistrano deploy: Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)

hi, I tried to deploy ror application on production server then got this error: Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error) but when i ran command: rake db:migrate RAILS_ENV=production it passed. I also connect to mysql from command line: mysql -u root -p it got through, and i can see all t...

which is best?? muliple table or single table??

HI I am still confused that whether I need to use multiple table in a single database or single table in single database?? I do have near about 30 columns for one record. ...