mysql

Simple MySql - Get Largest Number in Table

Hello, I need to use the MySQL Order By function in a query except I need it to be in reverse order by number - therefore like 45, 32, 12, 10 instead of 10, 12, 32, 45. I would then limit it to 1 so I would get the highest number in the list. However if you have another way to do this that would be great thanks :D Anyway thanks for you...

mysql service stops while trying to alter a table

I have mysql 5.1 installed using this: mysql-essential-5.1.49-win32.msi. And also have Workbench installed using this mysql-workbench-gpl-5.2.26-win32.msi On Windows 7 Now my problem that anytime i try to create a new table or alter an exist table, the mysql service stops and workbench gives an error that it can't connect. But before ...

How can I combine Join these two tables?

How can I combine Join these two tables? Table 1 SELECT job_category.JobCategoryId, job_category.JobCategoryName, count(job_position.JobCategoryId) AS AvailableCategories FROM job_position Right Outer JOIN job_category ON job_position.JobCategoryId = job_category.JobCategoryId GROUP BY job_category.JobCategoryId, job_category.JobCate...

Getting a MySQL group by query to display the row in that group with the highest value

I'm trying to figure out how to query my database so that it will essentially first ORDER my results and then GROUP them... This question seems to be slightly common and I have found examples but I still don't quite grasp the 'how' to do this and use the examples in my own situation.... So all help is definitely appreciated. Here are my...

MySQL INDEXES - Adding multuple columns to one index

I am still getting my head around MySQL INDEXES... A quick question... I have a table that stores a members location. It has a member_id and location_id columns... I do a MySQL query to find all the locations for a specific member... Would it be better to setup an INDEX like this: ALTER TABLE `members_locations` ADD INDEX `member_loca...

Getting the page a picture is on using its ID

I have a database containing 40 pictures. These pictures are displayed using a pager. I have a URL query: http://www.test.com/photo.php?id=15. This sets the current picture ID to 15. This picture is the 5th one on page 2. How can I get the page a picture is on given only the ID? SQL select * from photo limit 40 PHP $i=1; while($r)...

In hibernate, can we map date variable to long column-type in MySql

Hi, In the class i have variable with type Date. Now, can i store this data in MYSQL with column type BigInt. If it is possible, please specify me, how can i map this one in hibernate mapping. ...

mysql bind param needs a persistent(from bind to execution) object?

Hi, when i use prepared statement, i see mysql takes a pointer to MYSQL_BIND.buffer For example, to bind an integer i need to provide the pointer to integer rather than integer itself. Does it mean that the integer address should be accessible until the query ends? It would be convenient to bind a temporary object and then execute it...

changing timezone of mysql

I am using the CURRENT_TIMESTAMP for inserting records in database and I want to save the time in users timezone? Thanks ...

No OQGraph in my MariaDB?

Hello everyone! I've just installed MariaDB on my Ubuntu 10.04 Lucid Lynx, as explained in this blog: Unfortunately, there is no OQGraph engine in it. I must admit I'm a little bit confused between MariaDB, OurDelta, OpenQuery... I don't know who is doing what, but I would like to have OQGraph engine on my MariaDB. Can someone give me...

Mysql is it faster to use numbers in where clause compared to strings?

Lets say you have 4 types of assessments, Test, Quiz, MiniQuiz and FinalExam and we store records in the database like so studentid ----- assesType 1 test 2 quiz 3 quiz 4 quiz 5 miniquiz 6 miniquiz 7 final 8 final ...

SQL update query - Can you not specify the column names?

Hi Is it possible to write a update statement and not give the columns names. For example UPDATE tbl VALUES('1','2','3','4') WHERE id = 1; The number of values will always match the column count. Thanks in advance. EDIT I don't know the column names only the number of columns. I know i could delete the row and then do an insert b...

Php change date with respect to specified time.

Hi all. I have this question. I am using php, mysql and my files will be hosted on linux machine. Is it possible to change the date on a different format. I mean the date should change if it is 5PM. That is if today is 28th august 2010, then after 5pm it should show 29th august 2010. Thanks a lot. ...

calculate total number of days in specied dates

i have one table with two columns as shown in picture table columns names are (MAXDATE,AMOUNT). if you see we have first date range (from current date to 20-jan-2010) second date range from 20-jan-2010 to 30-jan-2010 3rd range is from 20-jan-2010 to 31-jan-2010. at the execution of page user enter the start and end dat...

MySQL InnoDB auto_increment value increases by 2 instead of 1. Virus?

There's an InnoDB table for storing comments for blog posts used by a custom built web application. Recently I noticed that the auto incremented primary key values for the comments are incrementing by 2 instead of just 1. I also noticed that in another MySQL table which is used for remembering the last few commenter's footprint signatu...

MySQL - select multiple maximum values

I have a table called order which contains columns id, user_id, price and item_id. Item prices aren't fixed and I would like to select each item's most expensive order. I want to select user_id, item_id and price in the same query. I tried the following query but it doesn't return the correct result set. SELECT user_id, item_id, MAX(pri...

NHibernate doesnt save object and also no error is showed

Hi, I have problem with saving object to database with NHibernate. Program throws no error but record is still not in database. I am also outputting sql queries and the query is not executed. I use composite key in table "order_product". Table is child of "order". Database table: order_product order_id (PK) product_id (PK) count pric...

GROUP domain from url in MySql

hello, I have a large database that contains many urls, there are many domains repeating and i;m trying to get only the domain. eg: http://example.com/someurl.html http://example.com/someurl_on_the_same_domain.html http://example.net/myurl.php http://example.org/anotherurl.php and i want to get only domains, eg: http://example.com ht...

How can I show four images per row and rows can be of any no with php

Dear Friends I have a Div of Images. <div class="img_team_container"> <div class="img_team_subcontain"> <div class="img_team"><a href="#" class="btn_1" title="Dining"></a></div> </div> </div> My question is that How can I show four images per row and rows can be of any no with php. ...

MySQL: select on a table with tablename from a recordset

I would like to do this in one step so I would like to know how can I: table a (documents) has: pk, document_id, template_id table b (templates) has: pk, template_id, template_table_name table c (template_table_name_1) has: pk, document_id, document_specific_columns so... I would like to query table a, get document_id and template_id...