mysql

How to store several HTML form fields in one mysql table field?

Hi, I want to store several fields from a html form in one table field. Here is the source code for the form. This is only part of the form, the form tags are there. Attached is a screenshort from this part of the form. <table border=0 cellpadding=0 cellspacing=0> <tr> <td><input class="field checkbox" type="checkbox" value...

MySQL - select multiple maximum values

I have a table called order which contains columns id, user_id, price. I would like to select each user's most expensive order - the order for which that user paid the highest price. I want to select order.user_id and order.price in the same query. ...

User selects operator from drop-down menu and use it in PHP function

Hi guys, What I would like to achieve here is a user selects an operator, e.g. +, >, <, >= etc. and uses this in a Select statement in PHP. MY HTML code: <label for="grade">Grade: </label> <select name="operator" id="operator"> <option value="">Select one</option> ...

Use order by DESC and ASC with Group By

Hello everybody, Here is my sql statement SELECT DISTINCT article_categories.category_id, article_id,article_title,article_intro,article_content, category_name_ar FROM articles,article_categories WHERE articles.category_id=article_categories.category_id AND article_type='admin' AND category_case='active' GROUP BY a...

Issues updating a MySQL table using Python's MySQLdb.

I am trying to UPDATE a MySQL table using Python's MySQLdb module. Although the query seems fairly simple it just won't update the information. Here is my code: for username,info in users.iteritems(): if info[0] > 0 and info[1] > 0: month = 8 year = 2010 cursor.execute(""" UPDATE users_disk SET ...

Best software (or other) solution for modeling existing complex MySQL schema

Hi Stack Overflow, What's a good solution for modeling an existing and very complicated MySQL schema. Preferably with the following features: completely visual drill down on click shows keys, indexes gives sample data per field* *as fields aren't always intuitively named Thanks! Emile ...

Mysql trigger to do an INSERT instead of an UPDATE

Hello, I would like to implement a basic versioning system in a MySQL table. Let's imagine a simple table with 2 columns: name (pk) and price. I thought I would simply add a column 'version' and add it to the primary key. Then I would catch all the UPDATE's and do an insert instead, incrementing the version number. First, is this pos...

Perl DBI fetchall_hashref

Consider the following table: mysql> select * from vCountryStatus; +-------------+------------+------+---------+--------+-----------------+ | CountryName | CountryISO | Code | Status | Symbol | CurrencyName | +-------------+------------+------+---------+--------+-----------------+ | Brazil | BR | 55 | LIVE | BRL ...

Index for a VARCHAR field with a 384 length in a MySQL database

I have a varchar(384) to store emails in a MyISAM table and I want check when the email exists but the index length limit is 333 bytes (because I'm using utf8 (1000 bytes/3 bytes)). Then what's the best way to search if a specified email exists, using a FULLTEXT index or creating another field with the email md5-hash in a BINARY(16) (wi...

PDO connection ID

Hi, is there a way to get s.th. like a connection id of a PDO connection connected to mysql? ...

Indexing on BigInt column in MySQL

i have a table which has big int column used for storing the time stamp.The time stamp value which we are getting from our application is 13 digit number like 1280505757693.And there are many rows in this table right now probably more than half a million entries.Should i use Index on timestamp column or not ???? Any suggestions ? ...

Secure voting website

I am willing to implement website where will be top 10 best members' pictures or something like that. Before voting for pictures or uploading pictures people will have to register first. But how could I protect my website from multiple accounts? Store IPs to database? But will it help me while there thousands proxies out there? What shou...

Are there any pitfalls with having multiple MySQL databases on 1 server node?

I want to prepare my database for sharding in the future. But right now I only need 1 node. What I'd like to do is to shard the database into virtual shards, say 12 shards, and put all of them onto the same server node for now. And when I need to scale out, I could just then get a 2nd server and move 6 of the 12 virtual shard onto the ...

Need an query help

SELECT rel.*,o.*,sr.*,sq1.*, (SELECT COUNT(*) FROM survey_questions sq JOIN survey_answers sa ON sa.iQuestionId = sq.iQuestionId WHERE sq.iQuestionId = '50') AS total_scale FROM survey_questions sq1 JOIN survey_response sr ON sr.iQuestionId = sq1.iQuestionId JOIN observer o ON o.iObserverId = sr.iObserverID JOIN relationsh...

Selecting multiple values from 2 columns in MySQL

Hi, I'm trying to select multiple values from 2 columns. I can get the query working with 1 column, eg: SELECT * FROM table WHERE town IN ( 'Oxford' , 'Abingdon' ) However, I want to do something like: SELECT * FROM table WHERE town IN ( 'Oxford' , 'Abingdon' ) AND type IN ( 'type1','type2') but I can't get it to work. Ba...

C# MySql connection cannot find host

I have a java program that connects to a MySql database and it's working fine. Now I want to convert it to a C# program, but I keep getting the error "Unable to connect to any of the specified hosts". I've already followed the following solutions: Connect to MySql with C# C# MySqlConnector Configure the ODBC DNS And the reference to M...

mySql - updating by comparig rows in same table

Hi, I want to update a column by comparing each row to all other rows in the table but I cant figure out how to distinguish the column names in the row being updated with the rows being searched through. Here's a simplified example... people: +--------+-----+----------------+ | name | age | nameClosestAge | +--------+----...

MySQL Select query - remove unwanted rows

I have a table with the following (I've sorted it by date): ID prodId date 16 532 2015-08-17 19 535 2014-08-18 18 534 2011-08-17 27 48 2010-08-26 26 1541 2010-08-25 25 1541 2010-08-21 24 1540 2010-08-20 21 48 2010-08-19 20 48 2010-08-18 17 53...

MySQL date comparison function

In my table dates are stored in the format "2010-08-26 09:00:00" so yyyy-mm-dd. I'd like to select all fields that have a date field that is "today", so between 2010-08-26 00:00:01 and 2010-08-26 23:59:59. Just using larger and smaller than operators does not work, does MySQL have some built in date comparison functions that can do this...

META value charset=UTF-8 prevents UTF-8 characters showing.

I've made a test program that is basically just a textarea that I can enter characters into and when I click submit the characters are written to a MySQL test table (using PHP). The test table is collation is UTF-8. The script works fine if I want to write a é or ú to the database it writes fine. But then if I add the following meta s...