mysql

JDBC & MySQL read performance

Hey, I really seem to have a big problem here. I'm using MySQL to store part-of-speech tagged sentences in a table. The Table looks like this: +------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+-------+...

Adding another db connection to function

I have a set of functions that handle the db connection. I want to add another connection here so I can access a different database at the same time as the current one. Any Suggestions? The reason I'm looking for a solution is because the script I'm using has very complicated Queries and I would like to be able to simply add the data...

Things which can be done with MYSQL instead of involving PHP

What are the must-know MYSQL functions (like IF etc..,) which every web developer should know? ...

How to set hibernate-mapping to allow for Strings longer than 255 characters?

So I'm trying to learn by creating a blog-engine. I'm using Hibernate with MySQL. Here is my hibernate-mapping for the "Post" class: <hibernate-mapping package="com.enw.blog"> <class name="Post" table="POST"> <id name="id" column="POST_ID"> <generator class="native"/> </id> <property name="title"/> <prop...

importing data into ALREADY CREATED mySQL database

Hi all, PROBLEM: importing data into ALREADY CREATED mySQL database I've done a lot of search online and know that I can import a CSV file into phpmyadmin in order for the table to be automatically created but I have created an empty table with the exact same fields as the CSV file but would like to just import the data itself. The ...

Use ADOX or ADOX and ADODB to query and edit data

I am trying to figure out how to use ADO and ADODB to get data and view it while also being able to determine the PK so that I can alter data. My plan is to use ADODB to display some data to an end user in Excel, if the user wants to edit the data there will be a macro monitoring cell changes and then sending the change to the database....

Multiple GROUP BY's & sort by SUM'd group values

I'm working on the reports for our time tracking app. Each time entry is related to a project and a service. Here a simplified query to group time entries by project and service. SELECT projects.name as project_name, services.name as service_name, SUM(minutes) AS minutes FROM `time_entries` JOIN `...

Export to html file

I am using php and mysql. I want to fetch data from table and export the output to the html file. Can anyone please help me out in this issue? Thanks. ...

Single MySQL query which checks another table for rows

I have a Users table and a Payments table. I need a query which lists the users who DO NOT have a record in the payments table where the field PaymentCompleted=1. These are the columns in the tables (simplified): Users: UserID, UserName Payments: PaymentID, UserID, PaymentCompleted The query should select the field UserName. ...

MYSQL: Avoiding cartesian product of repeating records when self-joining

There are two tables: table A and table B. They have the same columns and the data is practically identical. They both have auto-incremented IDs, the only difference between the two is that they have different IDs for the same records. Among the columns, there is an IDENTIFIER column which is not unique, i.e. there are (very few) record...

What is wrong with this format

SELECT .... GROUP BY c.city_id ORDER BY p.name desc UNION SELECT ... GROUP BY c.city_id, p ERROR 1221 (HY000): Incorrect usage of UNION and ORDER BY is there a way to have this format because i want the top query to have an orderby do i need to have the same orderby on the bottom query ...

Convert DAL function into Stored Procedures in mysql

Hi I have class for my Data Access Layer that contains a function called GetCitiesByLocation and it looks like this public DataTable GetCitiesByLocation(long pStateID, string pKeyword) { //create database object Database db = DBHelper.CreateDatabase(); //create SELECT sql statement to be executed using string builder /...

MySQL: how do I do in inline function with ORDER BY?

So, I want to create a formula for ordering things by popularity, but I don't want to create a stored procedure or function. I'd like the function just to be in my query. So, is there a way to do something like SELECT cols FROM tables WHERE conditions ORDER BY function(){ logic using cols } DESC LIMIT 10 or something like that? ...

php mysql forum app...how to make sticky threads?

Hi I am working on a mysql/php forum app as part of a corporate intranet system. My problem is that while listing all threads under a particular forum, there could be more than one "sticky threads" which should show on top and the rest should after them sorted by date in descending order. Just need to get an idea about the sql query to u...

mysql rows to columns, text type

If i have a table of data like Option_id|Component_id|Option_parent|Option_name|Option_value 1 1 0 id 2 1 1 option1 Some value 3 1 1 option2 Other 4 1 0 id Value 5 1 4 ...

Wordpress: events grouped by month

Hello Within my WP site I have a category called 'events' where I am publishing event information using two custom fields: eventdate = human readable event date eventsortdate = YYYY/MM/DD to list events in the correct order. I have this bit of code from a helpful post here: http://www.davidrisley.com/events-list-with-wordpress/ <?p...

mysql_num_rows returns 0, but the same query in phpMyAdmin return results

Hello all, We have been working for a few hours on a serious problem. We have the following code: mysql_connect("localhost","xxx","xxx") or die(mysql_error()); mysql_select_db("xxxe"); $q = "SELECT m.id, m.expired_date, u.email FROM jos_osemsc_member m, jos_osemsc_orders o, jos_users u WHERE o.order_id = $orderID AND m.m...

.NET MySql does "Using" closes the datareader?

I used to close an open datareader using the try/catch/finally block: Dim dr As MySqlDataReader = Nothing Try dr = DBConnection.callReadingStoredProcedure("my_sp") Catch ex As Exception ' the caller will handle this Throw ex Finally If dr IsNot Nothing Then dr.Close() End Try But I think it should be cleaner (and som...

Is using views for everything a crazy idea?

I'm working on building a MySQL database and I'm thinking that rather than encode a bunch of complex join queries in the front end I'll create a view for any queries I need and then have all the front end code do simple SELECT whatever FROM some_view WHERE something=5; queries. It seems like a great idea as it abstracts away the underl...

How to build multiple source feed parsing and data consolidating daemon?

I am given task to write a script (or better yet, a daemon), that has to do several things: Crawl most recent data from several input xml feeds. There are, like, 15-20 feeds for the time being, but I believe number might go up to 50 in future. Feed size varies between 500 KB and 5 MB (it most likely won't go over 10 MB). Since feeds ar...