mysql

Build category - sub category html list from mysql table

Hello, i have a table with categoryId, name and parentId. I would like to build a html list with parent and child tree like structure my table looks like this ------------------------------------------------------------------ id categoryId parentId categoryName SortSeq ----------------------------------------------------------...

Date Comparing Solutions

Using C# & MySQL Table1 ID Date1 Date2 001 04/05/2010 05/06/2010 002 04/06/2010 07/08/2010 ...., to Date2 Datatype is Varchar, Format: mm/dd/yyyy The Date always compare with system date, when the date is going to expire, it will show the message for i 1 week like this.. 7 days to expire 6 day to expire 5 day to expire ... ... 1...

How to fetch categories and sub-categories in a single query in sql? (mysql)

Hi, I would like to know if it's possible to extract the categories and sub-categories in a single DB fetch. My DB table is something similar to that shown below table cat_id parent_id 1 0 2 1 3 2 4 3 5 3 6 1 i.e. when the input is 3, then all the rows with parent_id as 3 AND the row 3 itself AND all t...

command line mysql database administration tool

Is there a command line script/tool I can use to administer a mysql database. I am in a tightly controlled environment and I can not use tools like phpmyadmin and can only access my database through command line (ssh connection). I can even live with something that can get show table status and describe all tables and write that into a t...

How can I update multiple rows with one query (perl-mysql) ?

I need to update multiple rows with one query. For the insert we usually do something like INSERT INTO `table` (c1,c2,c3) VALUES (1,2,3), (4,5,6), .. Yet how can we do something similar for the update where each row has different values than the other? And there is a condition that is related to the id of each row? Any one faced ...

How do I update a table from an array?

$query = "SELECT users FROM tabl ORDER BY RAND()"; $result = mysql_query ($query) or die ("Query '$query' failed with error message: \"" . mysql_error () . '"'); while ($row = mysql_fetch_array($result)) { $users[] = $row[0]; } $current = end($users); $partners = array(); foreach ($users as $user) { $partners[$user] = $...

MYSQL get other table data in a join

Hello, I am currently running this SQL SELECT jm_recipe.name, jm_recipe.slug FROM jm_recipe LEFT JOIN jm_category_recipe ON jm_category_recipe.recipe_id = jm_recipe.id WHERE jm_category_recipe.category_id = $cat" This returns the desired results except that I also need to return the name of the category that the recipe I am looking ...

php problem with encoding in a cli script reading id3 tags

i am trying to get a php cli script to go through a folder, get the id3 tags, which are in utf8 in cyrillic and but it in the database. when i execute the script i get the raw utf in the DB fields like "&#192;&#235;&#225;&#229;&#237;&#224;" here is the script <? set_time_limit(0); include('classes/adodb5/adodb.inc.php'); include ('cla...

how to get field name types from a sql database

To get field names one would use the command: select column_name from information_schema.columns where table_name='person'; My question is how would one also get the field types in a similar list? ...

DelayedJob and `master_slave_adapter`; losing the master connection

We have a Rails application that is running in a MySQL master-slave set-up for a while now, using the master_slave_adapter plugin. Recently, there was a need for background processing of long running tasks. So we settled on DelayedJob. DelayedJob's table/model uses the same master-slave adapter. And it keeps the slave connection alive b...

How do you sync a data-base from a test server to production server

If you have a test server, and a production server. How do you sync the database? Do you add the data in the test server first, just like you code in the test server? How is that generally handled? ...

How would you make this simple scheduler?

I'm working on an admin section right now to schedule employees for their shifts. It is simple in that on any day, employees work either the day or the night shift. How would you go about doing this so that it is easy to display? I was thinking I have a table with the employee names going down the first column. Then, the next 7 colum...

Use IF in a mySQL query

Hi, I'm trying to make a SELECT where I need to select a specified table by a column wich define the type of subject: table_buildings id name location source_type source_id 1 NY Appartament New York 0 NULL 2 Guggenheim Museum Manhattan 1 27 3 M...

ActiveRecord::Base.connection.update(sql) sometimes returns incorrent number of affected rows

I have a production web site with the following environment: Rails 2.3.5 MySQL Server 5.1.33 Enterprise Ruby 1.8.6 (2008-08-11 patchlevel 287) [x86_64-linux] mysql gem 2.7 Old version of BackgrounDRb plugin running on 4 different servers for background tasks, with 5 different workers each (Ruby threads, not separate processes!). One ...

mysql advanced delete

hopefully you can get what I want to do from the mysql query below. delete d1 from D as d1, D as d2 left join C rel1 on rel1.tld_tod_id=d1.did left join C rel2 on rel2.tld_tod_id=d2.did where d1.did!=d2.did and d1.name=d2.name and rel1.cid is null and rel2.cid is not null ; I got unknown column d1.did in on clause, how do I get it...

Fetch database information on a new page without using new documents

I'm working on a page where I've listed some entries from a database. Although, because the width of the page is too small to fit more on it (I'm one of those people that wants it to look good on all resolutions), I'm basically only going to be able to fit one row of text on the main page. So, I've thought of one simple idea - which is ...

How to get Field names from a SQL database into a list in python

Here is a the code I have so far: from ConfigParser import * import MySQLdb configuration = ConfigParser() configuration.read('someconfigfile.conf') db = MySQLdb.connect( host = configuration.get('DATABASE', 'MYSQL_HOST'), user = configuration.get('DATABASE', 'MYSQL_USER'), passwd = configuration.get('DATABASE', 'MYSQL_...

Ajax alert when a row has been added to a mysql database

I am trying to create a live orders page for my website. I need the page to auto-update to show that a new order has been placed and to display an alert/sound whenever a new order row is in the database. Any ideas on how i can easily achieve this? Thanks, -AJay ...

Package Java web app along with jboss, mysql and activemq for deployment

I have a springframework web application that uses JBoss, MySQL and ActiveMQ. At the moment, I have to install and configure JBoss, MySQL and ActiveMQ and JBoss manually. What is the best way to package the application so a user can maybe do a one click install (on Linux platform, maybe Windows too?) ...

Select from two tables to find vat rate based on effective date

Hi, I have this two tables: mysql> desc vat_rates; +-------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------+------+-----+---------+-------+ | rate_id | varchar(5) | NO | PRI | NULL | | | name | varchar(255) | ...