mysql

Best mysql datatype for grams, milligrams, micrograms and kilojoule

Hello, I'm very dubious about datatype of my database, I need to use different unit of measurements because I have different elements and different scales, and I'm sure about the limits used, because I take them from standard elements, but I'm afraid about the variety. Just consider I work with 100 grams of product and take from it all e...

Is there a MySQL setting to ignore "time" portion of datetime constant when applied to "DATE" column?

Disclaimer: this is needed for an old and ugly codebase that I'd much rather not touch. There is a table in the database that has a column (among many others) of DATE type. There is a query (auto generated by Torque criteria - don't ask) with java.util.Date parameter; Torque formats it as full datetime. So, the query MySQL is get...

MySQL lost after upgrading to Snow Leopard

I made a silly mistake of upgrading Leopard a tad too soon. I thought I dumped my mysql files but the last backup is about a month old. Now I upgraded the computer to Snow Leopard, and trying to run the old mysql server wasn't happening. So I read you must reinstall mysql with a newer version which I did and it ran just fine and starts...

how to show mysql field data inside flash php+mysql+flash

hello everyone i want to save my data to get copied from others so only option left to me is to show data inside flash i never done something this b4 if anyone guide me that will be great. i want to pass one mysql field inside flash tht contain text. so it wont be get copied. thanks ...

How to get data from a joined table

I have two table joined with c.id = p.category_id. I want to get categories.name but it gives an error. Could anyone tell me how to get data from a joined table please? function getGalleryone(){ $data = array(); $query = 'SELECT * FROM products AS p JOIN categories AS c ON c.id = p.category_id WHERE c.name ...

mysql - store embed codes (youtube, vimeo etc)

How best to store the html for embedding? the only ways I can think of are: take the embed html and add <?php echo $var1; ?> where the id's go then store it in the db and use Eval to execute it. or insert a strange combination of characters to act as a marker to be replaced in php by the id's. ...

Sending date to database with php

Hi guys I was wondering if you could help me if the folliwng: I have a calendar that inserts dates in hidden fields like this: <input name="selDay_start1" type="hidden" id="selDay_start1" /> <input name="selMonth_start1" type="hidden" id="selMonth_start1" /> <input name="selYear_start1" type="hidden" id="selYear_start1...

Personalized Welcome Messages

How do I create a welcome message on my home page with user's name in it? Dragging dynamic fields from the recordset onto my page does not work: <cfoutput>#Recordset1.Username#</cfoutput>. It keeps using the first username in the table, not the user I am logged in as. Do I have to add something to my Application.CFC page? I'm using C...

Mysql query optimization

Hi, I am working on a Rails project and hitting a performance problem. Here is the simplified db schema table gaming_platforms ( ~5 rows) id table games ( ~10k rows) id gaming_platform_id winner (black or white or n/a) black_id => online_players.id white_id => online_players.id table onlin...

MySQL local/online servers won't respond to C#/.NET

So, I'm sort of a beginner on C# and I'm working on this project that needs a connection to a MySQL database. I got MySQL's own library for this and, just to test the connection, I wrote this code: public object connectionTest() { MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); builder.Server = "local...

MySQL function to find the number of working days between two dates

Excel has NETWORKDAYS() function that find the number of business days between two dates. Anybody have a similar function for MySQL? Since holidays adds complexity, the solution doesn't have to deal with holidays. ...

MySQL - Oddities when doing a count, that I can't explain

Doing a simple query I'm finding two very different results, and I'm not sure how I'm coming to this conclusion. Below is the example, please let me know if its something I'm just over looking.. SELECT b.fkid as t, b.timestamp, count(b.fkid) as hits, count(distinct(b.fkid)) as num, DATE_FORMAT( b.timesta...

Selecting multiple "most recent by timestamp" in mysql

I have a table containing log entries for various servers. I need to create a view with the most recent (by time) log entry for each idServer. mysql> describe serverLog; +----------+-----------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+------...

Date conditions using Search logic

The Rails plugin - Searchlogic, from binary logic - offers the ability to filter by date. I have my form set up like so... <% form_for @search do |f| %> <%= f.label :start %> <%= f.select :due_at_after, [[['','']],['November', '2009-11-01'.to_date],['December', '2009-12-01'.to_date]] %><br> <%= f.label :end %> <%= f.select :du...

Problem calling MySQL stored procedure from php

I have a stored MySQL procedure that takes a customer number and a currency as input. It outputs an array using a select statement. The output array is comprised of Balance and NetBalance, If I call the procedure from MySQL as "call GetAccountBalanceByCurrency(500,'USD')" I get the correct results. However, if I call it from PHP as $...

Getting the total amount of results in a paginated query

In my RoR app, I have a query that could return anywhere 0 to 1000000 results, that I'm limiting to 16 and providing pagination for: find(:all, :conditions => conditions, :limit => limit, :offset => offset) I'd like to be able to tell the user how many results they're looking at vs. the total amount of results. Something like "Showing...

A single MySQL query for 'bouncing' table selects

So, say for the sake of simplicity, I have a master table containing two fields - The first is an attribute and the second is the attributes value. If the second field is set to reference a value in another table it is denoted in parenthesis. Example: MASTER_TABLE: Attr_ID | Attr_Val --------+----------- 1 | 23...

Differences case sensitivity in SELECT COLUMN and COUNT, mysql?

Okay, I am abit confusing here. In my database I have 5 rows of this data => "[email protected]" (all lower case), and This is my code, Query 1 (I am using php and mysql): $str = '[email protected]'; $sel = mysql_query("SELECT COUNT(*) FROM table WHERE `column` = '{$str}'"); $num = mysql_num_ro...

searching content of mysql fields

I have a table setup the following way `id` int(11) NOT NULL AUTO_INCREMENT, `eventid` int(11) NOT NULL, `invites` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) In that table i have rows which look like this 1, 127, '32215, 55648, 89887, 55555, 66666, 33333' 2, 168, '44444, 33333, 121212, 0540541' How would i se...

How to get the value of id(primary key) in previous operation in MySQL

I am using MySQL. I need to insert one row into a table first, then I need to get the id of the inserted row. The code looks somewhat like the following: insert into mytable (column2, column3, column4) values('value2','value3','value4')or die(mysql_error()); Column1 is the primary key and it is auto-increment. So how to ge...