mysql

how to get alphabetically next and prev records wiht minimal fetched records??

I have a page that is displaying a company name and its details from a table A. Now say i have a company displayed,and its name is 'Company_one' now i want to have alphabetically sorted next company and previous company and their details etc. The data in my table is not sorted.Its stored as it gets the data. So now what kind of query...

Conditional expression in SQL

Hello! I am using MYSQL and PHP. I have a table called item. Two of its attributes are price and discounted price.I have SELECT statement as below: $sql = 'SELECT C.cart_id,I.item_id,C.quantity, I.discounted_price,I.price FROM cart C, item I WHERE I.item_id = C.item_id'; I want to modify this sql statement and include a conditional ...

MySQL: add a field to a large table

i have a table with about 200,000 records. i want to add a field to it: ALTER TABLE `table` ADD `param_21` BOOL NOT NULL COMMENT 'about the field' AFTER `param_20` but it seems a very heavy query and it takes a very long time, even on my Quad amd PC with 4GB of RAM. i am running under windows/xampp and phpMyAdmin. does mysql have a ...

MySQL: a huge table. can't query, even a simple select!

i have a table with about 200,000 records. it takes a long time to do a simple select query. i am confiused because i am running under a 4 core cpu and 4GB of ram. how should i write my query? or is there anything to do with INDEXING? important note: my table is static (it's data wont change). what's your solutions? PS 1 - my table h...

php script that reloads the page

I'm having difficulty with pages that does not show the updated data immediately Here's my current one: <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("hospital", $con); $result = mysql_query("SELECT * FROM t2"); echo"<br>"; echo"<big>All In Patien...

MySQL: low cardinality/selectivity columns = how to index ?

Hello Experts, I need to add indexes to my table (columns) and stumbled across this post: http://stackoverflow.com/questions/141232/how-many-database-indexes-is-too-many Quote: “Having said that, you can clearly add a lot of pointless indexes to a table that won't do anything. Adding B-Tree indexes to a column with 2 distinct values...

Unable to restore from mysql database dump

Hello All, I have made a dump of my database in which one table is pretty huge (about 4 million records) and has good number of indices(One full text index along with a primary key and 3 unique indices). When i try to restore this dump the restore hangs(its been running for five days now) when it tries to execute the statement which ena...

Select an array per row?

I have 2 tables: 1. products - product_id - title 2. product_categories - product_id - category_id Each product can have more than one category. I store this information in the product_categories table. I want to be able to SELECT all the category_ids when I select a product in 1 query. How can I do this? I have the following so far, ...

Installing Apache Archiva Web Applicaiton on Tomcat (5.5 or 6) with MySQL backend

Has anyone been successful installing the web application version of Apache Archiva version 1.3 on Tomcat version 5.5 or with MySQL backend? I've followed the instructions to the letter, however, when Tomcat tries to deploy Archiva it says that it cannot find my JNDI datasources. I've tested my context file (in conf/Catalina/localhost)...

MySQL will connect on the command line with u/p but not mysqldump

It's driving me mad! I can connect to my server's MySQL via Terminal using: mysql -u admin -p and then password fine. Trying the same with: mysqldump --user admin --password=mypassword test123 > /backups/test.sql just gets me mysqldump: Got error: 1045: Access denied for user Any words of wisdom for me, do I need to grant more...

MySQL - SELECT ... GROUP BY ...

id - a_id - a_type --------------------------- 1 9 Granny Smith 2 9 Pink Lady --------------------------- 3 3 Pink Lady 4 3 Fuji 5 3 Granny Smith --------------------------- 6 7 Pink Lady 7 7 Fuji 8 7 Fuji 9 7 Granny Smith Ok, assum...

php mysql - spelling conversion?

Hi, I need to change UK spelling to US spelling for the content stored in the database(mysql). Is there any way to do this on the db itself? I found various software's(like a word add-ins) but to use these I need to have the data in a doc format, do the changes and export it back to mysql. Please let me know if there is a method using p...

How to get data 3 tables?

Hi, can u please show me how to query 3 tables using *? thanks ...

Find distinct count of group by user

I want to solve this issue in query @ for Ex : id ip 1 1.2.3.3 2 1.2.3.3 3 1.23.42.2 4 4.4.2.1 I am looking for ip count ids 1.2.3.3 2 1,2 1.23.42.2 1 3 4.4.2.1 1 4 I have tried with query - select count(id) ,ip , id from table group by ip ; it not working . how to solve this ....

a simple way to sum a result from UNION in MySql

I have a union of three tables (t1,t2,t3). Each rerun exactly the same number of records, first column is id, second amount: 1 10 2 20 3 20 1 30 2 30 3 10 1 20 2 40 3 50 Is there a simple in sql way to sum it up to only get: 1 60 2 80 3 80 ...

MySql Searching two tables and comparing columns with like and %

I am trying to select data from two tables and insert it into another one. I want to select the data when certain things match in each table. The problem is that one of the comparisons needs to be a like and I am at a loss. The sql statement is below and I believe that it will at least show what I am trying to do. insert into hr_numb...

Migrate data in mysql from old schema to new schema

Hello, We have recently improved the schema of our production database, changing column names and indexes etc. We also changed the storage engine to InnoDB to make use of transactions and foreign keys. What is the best way to import the data from the old schema into the new schema? Bare in mind that column names have changed (including...

What does @V1 mean in MySQL?

There is a project that I need to maintain that talks to mysql via jdbc and there is an insert statement that looks like this: loadStr.append("IGNORE INTO TABLE xxx.inventory (tn, @v1, @v2, @v3)"); What does the @v# mean? ...

How to increase last day count query performance

I have a table Products with products and table Sales with all sale operations that was done on these products. These tables are connected by Sales.PRODUCT_ID column. I would like to get 10 most often sold products today and what I did is this: SELECT product.* , COUNT( sale.ID ) SUMSELL FROM Products product LEFT JOIN Sales sale ...

Secure encrypted database design

I have a web based (perl/MySQL) CRM system, and I need a section for HR to add details about disciplinary actions and salary. All this information that we store in the database needs to be encrypted so that we developers can't see it. I was thinking about using AES encryption, but what do I use as the key? If I use the HR Manager's pas...