mysql

Mysql alternative for LIMIT inside subquery in mysql 5.1.49

SELECT student_id FROM `students` AS s1 WHERE student_id IN (SELECT s2.student_id FROM `students` AS s2 WHERE s1.year_of_birth = s2.year_of_birth LIMIT 10) Can't process this query on my server. It drops errors, that says that this version of mysql doesn't support limit inside subqueries etc(ERROR 1235). Is there any solu...

RSS generator with caching function

Do you happen to know any good rss generator script with caching function. All the script I have found over the net so far doesn't support caching! I need the the content of rss to be generated automatically from database in a specified period of time. Thanks in advance ...

Insert 52 weeks for each year in MySQL (PHP script)

Hi, I want in a table called week_year with following schema: Week_year = {id, week, year} To insert the weeks for each year, such that, for 2001 there is week 1, week 2, week 3, … , week 52, and then start over for year 2002 up until the year 2009. I’ve tried different PHP scripts but can’t seem to be getting it right. I’ve tried ...

PHP secure user variable

On my website I have a variable called $user_data that contains input from a form. I then show this variable on the user page (via echo). What is the best method to avoid any security risks with this variable? I use strip_tags(), but it is not enough. This variable also gets saved to a MySQL database. ...

how to store the data in a object array, which collected from data base?

Here, i have coded to get data from DB. I want to store the data in Object Array(POJO). How to do it? This code can also insert Data into DB, but omit it. import java.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sq...

JSTL: How to access table row contents using index

Hello, My question is: How can I access row information using index in JSTL? i am using MySQL 5.1.47 Server as Relational Database Server For example, I have a table name login with two attributes “username” & “password” and this table contain 10 records. I want to extract only first record information. How can I do this? I have ...

Table too big in MySQL database

Hi. I am making an online game and one table in my database. The most important one maybe. It's starting to become very large. I am creating a function where you can go together with multiple users and for that I have a table that look like this so far: CREATE TABLE `oc` ( `id` int(11) NOT NULL auto_increment, `leader` varchar(40) N...

How to update table1 with content from table2 with php and mysql

I have two tables in my database, table1 and table2. They are identical. But sometimes i change the data in table1. How do i copy the data from table1 and update table2 to look the same? I tried "REPLACE INTO table2 SELECT * FROM table1" but it works like INSERT and just make new rows instead of updating the existing ones. ...

MySQL how to fill missing dates in range?

I have a table with 2 columns, date and score. It has at most 30 entries, for each of the last 30 days one. date score ----------------- 1.8.2010 19 2.8.2010 21 4.8.2010 14 7.8.2010 10 10.8.2010 14 My problem is that some dates are missing - I want to see: date score ----------------- 1.8.2010 19 2.8.2010 21 3.8.2010...

PHP: What is the best method to SQL query an array? (if you can)

Consider this: One mySQL database that has tables and rows and data within it. One array that has the same data. Now normally, I would have a query like this for mySQL SELECT * FROM 'table' WHERE name LIKE '%abc%' But I want to perform that same query on the array, without having to insert it yet. The only method that comes to mind i...

Display my DB queries on other websites

What can I make to allow people to display data from my own website's database on their website using a query? For example if I have a table named "movie_quotes" which is comprised of various movie quotes.. How can other people query them on their own sites by either genre or dates. For example they can modify the "category" parameter t...

In InnoDB, are columns which are not part of index stored in sorted order as well?

I am using InnoDB. My Index selectivity (cardinality / total-rows) is < 100%, roughly 96-98%. I would like to know if the columns, which are not part of the keys, are also stored in sorted order. This influences my tables' design. Would also be interest to understand how much performance degradation in lookup I can expect when index s...

Mysql fetch array error.

Im getting an error on my site that appeared for the first time today, despite functioning fine for months. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web_directory/index.php on line 33 Here is the code from those lines. <? $sql = "SELECT p.id as 'id', p.post_...

Mysql Select record based on last run

I have a table which has following fields project_name VARCHAR (100) running_frequency enum ('daily', 'weekly', 'monthly') last_job_run DATETIME I want to select those records which are due now based on last_job_run field. For instance, if a task has run yesterday and daily is selected then I need a query to select the re...

Create array of hierarchical directories in PHP

I have the following code (I know that this code is not optimized but it's not for discussion): function select_categories($cat_id) { $this->db = ORM::factory('category') ->where('parent', '=', $cat_id) ->find_all(); foreach ($this->db as $num => $category) { if($category->parent == 0) ...

Bind_param Non-Object Error w/ mysqli

When attempting to insert the initial row for a table that will track daily views, I am getting the error: Fatal error: Call to a member function bind_param() on a non-object in /.../functions.php on line 157 That line is the last of the following group: if($stats_found) { $sqlquery = "UPDATE vid_stats SET views = ? WHERE title =...

Selecting the highest salary

Assuming a wagetable: name lowhours highhours wage Default 0.0 40.0 100 Default 40.0 50.0 150 Default 50.0 70.5 154 Default 70.5 100.0 200 Brian 0.0 40.0 200 Brian 40.0 50.0 250 Brian 50.0 60.0 275 Brian 60.0 7...

SQLite: Combining an OR and AND

This is continuing questions from http://stackoverflow.com/questions/3539673/sqlite-selecting-the-highest-salary Assuming a table 'wagetable' name lowhours highhours wage priority Default 0.0 40.0 100 0 Default 40.0 50.0 150 0 Default 50.0 70.5 154 0 D...

Does MySQL Workbench need server to operate?

I have to solve problem with the database connection. I checked the ip address and port but my pc's host doesnt allow the connection. Do I have to own a server to use MySQL workbench? ...

Multiple HostNames and Multiple Privileges?

Hi all, I want to map 127.0.0.1 to multiple names instead of the standard way as localhost. so my /etc/hosts file in ubuntu would have the following entries 127.0.0.1 localhost 127.0.0.1 localhost:extra1 127.0.0.1 localhost:extra2 Now, In my sql, i want to have a user named karthick and it should have different privile...