mysql

How do I add a one-to-one relationship in MYSQL?

+-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | pid | varchar(99) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 1 row in set (0.00 sec) +-------+---------------+------+-----+...

MySQL query advice

I am lost in MySQL documentation. I have a table with votes - it has these columns id song_id user_id created I cannot find the query which will process the information and output the 10 most voted songs in a given time period. What is it? ...

many-to-many query

Hello, guys! I have a problem and I dont know what is better solution. Okay, I have 2 tables: posts(id, title), posts_tags(post_id, tag_id). I have next task: must select posts with tags ids for example 4, 10 and 11. Not exactly, post could have any other tags at the same time. So, how I could do it more optimized? Creating temporary tab...

MySQL float values jumping around on insert?

So i have a SQL table setup as such CREATE TABLE IF NOT EXISTS `points` ( `id` int(11) NOT NULL auto_increment, `lat` float(10,6) NOT NULL, `lng` float(10,6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM; And im inserting stuff like INSERT INTO `points` (`lat`, `lng`) VALUES ('89.123456','-12.123456'); Gives me a row with l...

How to Connect Crystal Reports to MySQL directly by C# code without DSN or a DataSet

How can I connect a Crystal Report (VS 2008 basic) to a MySQL DB without using a DSN or a preload DataSet using C#? I need install the program on several places, so I must change the connection parameters. I don't want to create a DSN on every place, nor do I want to preload a DataSet and pass it to the report engine. I use nhibernate t...

Learning Php MySql queries, How to show the result in PHP?

Hi, im just need the easiest way in php to navigate in this result: $datos = mysql_query("SELECT * FROM usuarios LIMIT 0, 30 "); I mean, how do i do an echo from $datos in each element of the table? Ex. Table: ID Name LastName 1 Domingo Sarmiento 2 Juan Lopez How can i read for example the second last name? ...

Send mail every n days

Hello all! I have a php script that i use to send mail to customers. How can i execute this script every 5 days for example? Can anyone give me an idea or some links? Thanks ...

Order a MySQL result by Date and Time in PHP

Hi, i have this code: $datos = mysql_query("SELECT * FROM `usuarios` LIMIT 0, 30 "); Who is a simple MySQL query in php, but i need the result organized by date and time. There is a field in my table who has this value (automatic inserted when the user sing up in my page). So the table is something like this: Id Name DT 1 Dom...

MySQL query pulling from two tables, display in correct fields

I'm trying to select all fields in two separate tables as long as they're sharing a common ID. //mysql query $result = mysql_query("SELECT * FROM project, links WHERE project.id = links.id and project.id = $clientID") //displaying the link if ($row['url'] != null){ echo "<div class='clientsection' id='links'>Links</div>"; ec...

Is it possible to create multi-tiered WHERE statements in mySQL

I'm currently developing a program that will generate reports based upon lead data. My issue is that I'm running 3 queries for something that I would like to only have to run one query for. For instance, I want to gather data for leads generated in the past day submission_date > (NOW() - INTERVAL 1 DAY) and I would like to find out how...

SugarCRM installation frozen

Hi there. I'm trying to install SugarCRM version 5.5.1. on a webhost. Everything goes nice until the step when the installation begins. The output is this one: Creating Sugar configuration file (config.php) Creating Sugar application tables, audit tables and relationship metadata ............. And never moves on! ...

what data type for 11.1234 in mysql?

i wonder what data type i should use for storing 11.1234 in mysql? varchar or int? they got some decimal data type? thanks ...

Truncated MySQL field when connections from MS Access

I have created a linked table to a MySQL table in MS Access 2003. I used the the mysql-connector-odbc-5.1.6-win32 driver I found on the MySQL site. When I view the table I can only see 70 characters in a VARCHAR(255) field. Has anybody had any luck using MySQL from MS Access? ...

MySQL access classes in PHP

I have a connection class for MySQL that looks like this: class MySQLConnect { private $connection; private static $instances = 0; function __construct() { if(MySQLConnect::$instances == 0) { //Connect to MySQL server $this->connection = mysql_connect(MySQLConfig::HOST, MySQLConfi...

Mysql - Summary Tables

Which method do you suggest and why? Creating a summary table and . . . 1) Updating the table as the action occurs in real time. 2) Running group by queries every 15 minutes to update the summary table. 3) Something else? The data must be near real time, it can't wait an hour, a day, etc. ...

Pass Array to a MySQL stored procedure

How can we pass an Array to a Stored Procedure in MySQL 5.1 so that I can use it like: Select column1 FROM table where column2 IN in_array Thanks ...

ON DELETE RESTRICT Causing Error 150

CREATE TABLE project ( id INTEGER NOT NULL AUTO_INCREMENT, created_at DATETIME NOT NULL, name VARCHAR(75) NOT NULL, description LONGTEXT NOT NULL, is_active TINYINT NOT NULL DEFAULT '1', PRIMARY KEY (id), INDEX(name, created_at) ) ENGINE = INNODB; CREATE TABLE role ( id INTEGER NOT NULL, name VARCHAR(...

Update query with conditional?

I'm not sure if this possible. If not, let me know. I have a PDO mysql that updates 3 fields. $update = $mypdo->prepare("UPDATE tablename SET field1=:field1, field2=:field2, field3=:field3 WHE...

How to combine a Distance and Keyword SQL query?

Hi Folks, I have a tables in my database called "points" and "category". A user will input info into both a location input and a keyword input text box. Then I want to find points in my table where the keyword matches either the "title" field in the points table, or the "category" but are within a certain distance from the user's loca...

Updating Checked Checkboxes using CodeIgniter + MySQL

Hello I have about 8 check boxes that are being generated dynamically from my database. This is the code in my controller //Start Get Processes Query $this->db->select('*'); $this->db->from('projects_processes'); $this->db->where('process_enabled', '1'); $data['getprocesses'] = $this->db->get(); //End Get Processes...