mysql

Selecting 2 distinct rows MySQL

I have a table called categories that has 3 columns: id, name, parent_id. ID name group_id == == == 1 haim 1 2 gil 2 3 alon 1 4 idan 1 5 shai 3 6 adi 2 7 itay 3 8 aviram ...

How to find total no of '1' in the table?

Hey Friends Here is the table details and data id data h1 h2 h3 h4 h5 h6 h7 h8 1 2010-10-10 1 1 1 1 1 1 1 1 1 2010-10-11 1 0 1 0 1 0 0 1 1 2010-10-12 0 1 1 1 1 0 0 0 what i need to know is how can i create query for following find total no of zero in h1-h8 for id 1 find total no of one in h1-h8 for id 1 find total of data in h1-h8...

Connect to web MySQL from c# desktop program?

I've got a webserver running quite standard Apache/php/MySQL and want to connect to this MySQL database from a desktop application written in c#/wpf. First, how can I connect? Do I need some special SQLConnection library? Second, how safe is this? Anything special I need think about for security since the database is in the web and not...

mysql PDO SET statement encounter errors

I was looking for something that is related to a mysql query and I stumbled to this link mysql variable usage and saw the stored proc-like variable setting. I've tried it in phpmyadmin : SET @value = 5; SELECT @rank; and it is working, but when I tried to place it in PDO statements, it does not work. $value = "SET @value = 0"; ...

How to get result from database on the change of values in text box using Ajax?

I am working in PHP and Mysql Combo I need to search the results from DB and store in a hidden field , on change of the value user inserts in a text box. How can I do this Using Ajax? ...

What is the best way to store Time Series in MySQL?

I want to store a large number of Time Series (time vs value) data points. I would prefer using MySQL for the same. Right now I am planning to store the time series as a Binary Blob in MySQL. Is this the best way, what would be the best approach. ...

selecting id and count(id) from table in mysql

Hi guys, I am trying to make a photo album system in php and mysql. I have this code for list all photo albums: SELECT albums.*, count(pictures.id) AS countpic FROM albums LEFT JOIN pictures ON (albums.id=pictures.album_id) GROUP BY albums.id ORDER BY albums.date DESC"); I want to list title of photo albums with photo thumbnails ...

How to prevent multiple authentication in a web app / site?

Hello, There's a site with registered users area, they all have their own user/pass. The problem is, some of then try to share the authentication info with others to help them finish their job. There's no posibility to restrict by ip adress because there's a dynamic-ip provided for everyone. What could be the best solution? store ses...

Inserting/Updating rows with some columns and preserve values of others

A little background information: I have a table called table_a, which has 12 columns. I want to insert or update rows with values for 6 of these columns, while I don't wanna lose the data in the other 6 columns. And I wanna do this with a parameterized query in C#. field1 is Unique. > SELECT * FROM table_a; +----+--------+--------+---...

MySQL ORDER BY optimization in many to many tables

Tables: CREATE TABLE IF NOT EXISTS `posts` ( `post_n` int(10) NOT NULL auto_increment, `id` int(10) default NULL, `date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`post_n`,`visibility`), KEY `id` (`id`), KEY `date` (`date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; CREATE TABLE IF NOT EX...

auto_increment usage in composite key

I am having a table with the composite key emp_tbl( companyId int not null, empId int not null auto_increment, name varchar2, .... ... primary key(companyId,empId) ); In mysql whats happening is while i starts inserting the data Emp_tbl companyId empId 1 1 1 2 1 3 2 1 2 ...

PHP."INSERT INTO" run twice via PHP mysqli_query!

for($j = 0 ; $j < 87; $j++){ echo $j.'<br/>'; $unique = mt_rand(0,100000000); $insert_data = 'INSERT INTO uniques(uniq) VALUES ("'.$unique.'")'; mysqli_query($conn , $insert_data); echo $unique.'<br />'; } I just want to insert random number into table uniques. But something wrong with above code.It w...

uploadify and sql query

Hello, i am using uploadify script to upload files as my school project. //die($_SESSION['ID'].'.....'.$_SESSION['level']); if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; $filename = substr(md5(time()), 0, 8)."-".$_FILES['Filedata']['...

how to send email by using triggers in mysql?

i am new in trigers working.how to send email by using trigers in mysql? ...

Store UTC date time in database

I will convert all date & time input by user (local time) to UTC and store it in database. When display back I will convert UTC time to their time zone which is set in their profile. Is it good? ...

Appending record & Making it "selected"

I have a form which takes info on events. In addition to the fields are a couple of lists which are created by php using values stored in other tables of the db. If the user wants to add an , I want to take the data from a 'quick form', insert a new record in the appropriate table, then make that record the selected="selected" reco...

How can I write a SQL query which ensures two columns are independently unique?

I have a MySQL table which looks like the following: user_id resource_id last_used -------------------------------- 1 1 2010-09-01 1 2 2010-09-02 1 3 2010-09-04 2 3 2010-09-08 2 2 2010-09-03 3 1 2010-09-01 3 1 ...

MySQL Merge tables - high-traffic and large amounts of data

My work currently uses MySQL (MyISAM) exclusively for all data storage. We currently have over 300 webservers and about 150 databases. Unfortunately I'm in a position to have to write a table structure to support over 100 million rows in a 30 day period. The idea is: High volume inserts (no updates or deletes and always at the end of t...

Can a enum value in phpmyadmin be like this? 'Readme'=>1

In this, I would see Readme, but the value would be set to 1 Is this possible? edit; Sorry. Basically I have a site. It's navigation is in the database. It need to display nav items depening on the users state, like, logged in , admin, blogger, not loggin, and indepenant. These work, however I would like to move from numerical values t...

Sort out the three first occurence of an attribute

Hi! I'm a beginner in MySql. But I am creating a calendar application, where I have a database of future event posts. The event post have the attributes: id, title, startTime, endTime, startDate, repeat. Where the last attribute repeat, is if the event post shall be repeated weekly, monthly or none start by startDate. I want a sql-quer...