mysql

MySQL JOIN with WHERE

I have the following query: SELECT * FROM (SELECT t1.`id`, t1.`vehicle`, lp1.`veh_no` AS `lp_vehicle`, t1.`last_date`, t1.`due_date`, t1.`driver`, lp4.`employ_name` AS `lp_driver` FROM `inspection` AS t1 LEFT OUTER JOIN `vehicle` AS lp1 ON (t1.`vehicle` = lp1.`id`) LEFT OUTER JOIN `employee_driver` AS lp4 ...

Detect how much stress the mysql database is currently under with PHP

I am developing a large web app and want it to alter itself dependent on a factor that relates to the stress the database is currently under. I am not sure what would me most accurate/effective/easiest. I am considering maybe the number of current connections or server response time or CPU useage? What would be best suited and possible...

One-to-one relationship or One-to-many?

Maybe I need more coffee this morning but here goes... I have a very simple inventory system. Right now I have two tables: Items and Inventory. Items Id Title YearReleased Inventory Id ItemId(Foreign key to Items) Quantity QuantityOnHand Each item has one inventory and each inventory belongs to one item. The relationship betwe...

Storing selected option value in Database

I currently have an array I created like this: $regions=array( 1=>'North West', 2=>'North East', 3=>'South West', 4=>'South East', 5=>'West Midlands', 6=>'East Midlands', 7=>'London', 8=>'Yorkshire', 9=>'East England', 10=>'Scotland', 11=>'Wales', 12=>'N. Ireland', ); I will use this arr...

Set -1 to 0 while adding in MySQL

I've got a database using DECIMAL type values for various tests on crude oil. When running these tests you run into certain cases: 1.) Test was run and value is found; 2.) You can definitively say nothing is there (0 in database); 3.) Test was not run (NULL in database); 4.) There is something found, but testing is not accurate enough t...

Using a different MySQL database engine

Hello, I am having problems trying to use a different MySQL database engine. (I want to change from MyISAM to InnoDB) /etc/my.cnf [mysqld] bind-address = 127.0.0.1 default-storage-engine=InnoDB It appears that it is not installed? If that is true, how can I install InnoDB? mysql> show engines; +------------+---------+-------------...

Win7 MInGW QT MySQL program screams "cannot find -lqsqlmysqld"; where is the missing library?

Hello everyone. I am attempting to make a qt program on Windows 7 that uses a MySQL plugin. I have compiled both qt and the mysql plugin with no problems using my minGW 32bit compiler. However, I keep on getting an error like this: mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory `C:/Users/dhatt/Desktop/testdb2' g++...

How to order MySQL records by Unix timestamps in descending order?

How do I order records in a PHP query to MySQL by a field that contains TIME() timestamps in descending order? ...

Can't get head round mysql subquery

Im having trouble getting my head round subqueries in Mysql. Fairly simple ones are ok, and most tutorials I find rarely go beyond the typical: SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2); What I am trying to pull out of my database is the following (I'll try my best to explain this without any background on our db): Re...

createing wamp server with cygwin ?

i notice that in cygwin we can install apache2. can we make a wamp with cgywin ? ( php mysql and apache ) better with phpmyadmin ? or we cant do that ? if we can, please give me a tutorial to learn on. Thanks Adam Ramadhan ...

Spring-Batch for a massive nightly / hourly Hive / MySQL data processing

I'm looking into replacing a bunch of Python ETL scripts that perform a nightly / hourly data summary and statistics gathering on a massive amount of data. What I'd like to achieve is Robustness - a failing job / step should be automatically restarted. In some cases I'd like to execute a recovery step instead. The framework must be ab...

Incrementing a click counter in MySQL

How do you increment a value in a mysql table by one each time for example if a link is pressed ? Do you get the data from the database and then add 1 to it and then send it back ? I assume that would use a lot of bandwith. Any examples and help would be appreciated, Thank you! Added: I would also like to keep track of who has pre...

mysql distinct value for count

I am all over the place here. The MySql query below works for me except for two issues. 1) I want to make sure that only one result per category is displayed (I have 5 categories), I tried using DISTINCT but have clearly misunderstood that one. 2) I want to be able to return the howmany value outside the sql query: "SELECT DISTINCT ca...

Creating MySQL stored procedures using MySQL

Is there a way to programmatically create stored procedures using MySQL? I can write a stored procedure to create databases and tables using prepared statements, but I get an error message saying it is not supported to create stored procedures with prepared statements. I realize I can do this in PHP or Java, but so far I have been kee...

How to provide security to my web site?

How to protect my site from being hacked?just suggest some methods that are in common? i am using php for scripting & mysql for database and i am using CodeIgniter(php framework). if you know some good tutorial or ebooks then provide me some link -Abhijeet ...

How can I select the database record with the most vote_points and ensure that it is displayed first? PHP / Kohana 3

Hello everyone and as usual, thank you to anyone taking the time to read this. I am attempting to display all of the answers relevant to a question that has been asked. I am using Kohana 3. So far, I am able to determine which record has the highest amount of vote_points via: $best_id = DB::query(Database::SELECT, 'SELECT id FROM ans...

@Column(unique=true) does not seem to work

Even though I set the attribute to be @Column(unique=true), I still insert a duplicate entry. @Entity public class Customer { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Column(unique=true ) private String name; ... } I set the name using regular EL in JSF. I did not create table ...

PHP/MySQL query character limit?

So I've got a relatively long query as follows: SELECT ( (CASE Methanethiol WHEN -1 THEN 0 ELSE Methanethiol END) + ... + (CASE nHeptanethiol WHEN -1 THEN 0 ELSE nHeptanethiol END) ) FROM condensates.mercaptans WHERE ( (CASE Methanethiol WHEN -1 THEN 0 ELSE...

Retrieve order numbers without certain items

I have a table with some ice cream order data like so: id order_number item_name 1 1 cake cone 2 1 sprinkles 3 2 sugar cone 4 3 semi-sweet morsels 5 3 sprinkles (This is simpler than the real table but the relevant columns are present.) Essentially what I want to...

Mysql num rows on multiple tables using UNION

Hi all, I'm trying to find number of rows for two tables: Example 1 returns 81 (which is wrong). SELECT p_id FROM j_posts INNER JOIN j_blogs ON p_blog_id = b_id && b_approved = 1 WHERE p_is_draft = 0 UNION SELECT ep_id FROM j_external_posts INNER JOIN j_blogs ON ep_blog_id = b_id && b_approved = 1 I have then tried to split up th...