mysql

Issue in date comparison in MySQL

I have MySQL with below settings Server version: 5.0.77 MySQL client version: 5.0.41 Protocol version: 10 MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: utf8_unicode_ci I am just doing a simple query and it returned wrong SELECT * FROM table1 WHERE mydate >= '2010-08-30' Today is 8/30 and I have 1 row with mydate is '2...

PHP how to display multiple array values.

How can I display array values that I retrieved from the database for example the following array values. while($row = mysqli_fetch_array($query)){ $post_id[] = $row['id']; $post_user_id[] = $row['user_id']; $post_title[] = $row['title']; } Output. <li><a href="' . $post_user_id . 'post.php?id="' . $post_id . '">' . $post...

adding fulltext query to existing query

I am struggling to work out the syntax for joining a normal multi table query with single table fulltext. I can't get my head around the syntax This is the existing syntax which works fine: SELECT * FROM products,categories,sub_categories WHERE products.approved = 1 AND products.main_category = categories.id AND products.sub_cate...

How do I sort the top 10 entries in descending order in mySQL?

I have a table holding entries which can be sorted by rank. I want to get the top 10 entries (which is simple using SELECT * FROM table ORDER BY rank DESC), but then I want those entries in descending order, so the one with the lowest rank ends up at the top. How would I do this? ...

PHP & MySQL best way to count page views for dynamic pages

What is the best way to count page views for dynamic pages like the url example below? I'm using PHP and MySQL. A brief explanation would help. Thanks! http://www.example.com/posts/post.php?id=3 ...

mysql timezone and current_timestamp

Hi, I have changed the timezone of my server per connection basis which is working fine but most of the addedon Fields in my database tables and timestamp and I am using the CURRENT_TIMESTAMP default value for them to add the inserted date. Now as I have changed the timezone but this change is not affecting the dateadded fields of m...

Fetch only N rows at a time (MySQL)

I'm looking for a way to fetch all data from a huge table in smaller chunks. Please advise. ...

MySql, .NET, Stored Procedures sharing the current date and time with the calling client

I'm writing a stored procedure to update a table: UPDATE st SET somedate = NOW(); The client of the SP must know the exact date and time generated by the NOW function. There are two options: 1) the client passes an input parameter (called _now) to the SP giving it the current date and time UPDATE st SET somedate = _now; 2) the S...

how to update new indian currency symbol in both mysql and sqlserver database

Hi all, Can anyone help me regarding our new currency symbol up-gradation in databases. how to update new indian currency symbol in both mysql and sqlserver database. Please help me. Thank you Gokul. ...

JPA/Hibernate can't create Entity called Order

Hi, I'm using Hibernate/JPA and have an @Entity object called Order, pointing at a MySQL database using Hibernate's dynamic table generation i.e. generate tables at runtime for entities. When Hibernate creates the tables, it creates tables for all of my entities except the Order entity. If I rename the Order entity to something else e.g...

How to extract schema from mysql database

Hi, I would like to extact my database(Mysql database) schema in the graphical format or xml format. could any one help me out in this process.. Pl. help me by providing step by step to extract the schema from mysql database, if possible. I am using Linux ubuntu machine. thanxs ...

Query local MySql database

I'm just getting started with MySql and need to run simple queries on the local database file. But I keep running into the same error: "Can't connect to MySql server on '127.0.0.1'" So wierd since you would think the machine can connect to itself... I started with this tutorial, but got stuck at step 15. When I test the connection, it g...

MYSQL query / dates older than 1 week ago (all datetimes in UTC)

Hi, How do I query a mysql db to return all records with a datetime older than 1 week ago. Note that the datetime table stores everything in UTC, and i should be comparing it in that itself... Jusst to be clear - I'm looking for a pure mysql query ...

Combining two PHP variables for MySQL query

I have a variable formvar that is incremented every time a user adds an additional field in an HTML form. This variable is posted to the PHP script for the purpose of looping through all of the added fields. I am trying to combine two variables in the MySQL query to match what is in my HTML form. I would like the MySQL query to go upc0...

mysql - can I set VARCHAR default value as NULL?

In mysql, i tried changing an existing table like this: ALTER TABLE `etexts` CHANGE `etext` `etext` VARCHAR( 100 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT NULL I got the response: #1067 - Invalid default value for 'etext' Why? ...

Return multiple rows on a single record

Hi All, I need to retrieve this result: ROW1.id | ROW2.id | ROW3.id | ROW4.id 1 | 2 | 3 | 4 starting from this result select * from Table: id | value 1 | sample1 2 | sample2 3 | sample3 4 | sample4 any idea? thanks, Andrea ...

MySQL Custom Order

Hello! I have a table that I select data from with a column called parent that's of unsigned integer type. It has numbers from 0 to 12. I want to select * from table order by parent asc, but with one exception: place the 0 at the end of the select so it would be like 1,2,3,4,5,6,7,8,9,0. Is this possible with a single select in MySQL...

SQL IF THEN for concatenating fields

I have two columns that are minimum price and maximum price. Most of the time, the min_price and max_price is the same. Instead of two separate fields for the price, I would like just one "price" field. If the min_price and the max_price are the same I want to display that price. If the min_price and max_price are different, then I w...

Infinite PHP while loop

Hi guys, I am having some trouble with a basic PHP while loop, everytime I launch my test_post.php file in my browser, I get a never ending loop, and I have no idea what I am missing! Here is my PHP code: <?php mysql_connect('localhost', 'admin', '1234') or die(mysql_error()); mysql_select_db('json'); $test = mysql_query('SELECT us...

Convert sql row into columns

Hi, I have a table: A B c a1 1 a11 a1 2 a12 a1 3 a13 a2 1 a21 a2 2 a22 a2 3 a23 and I want to convert it to: A C1 C2 C3 a1 a11 a12 a13 a2 a21 a22 a23 How can I write a SQL query to achieve this... I do not want to convert my table to csv and use python and d...