mysql

convert datetime to timeticks in php and mysql

i want to convert datetime.now() to ticks, like is the time is 4:00 PM on june 18th 2010, i want it to be 20100618160000, or some complex number like this. I want to use this number and another field in my database as the primary keys combination to retrieve data. I am using php and mysql so it would be very helpful if someone could send...

Codeigniter PHP url segments for users profile

I need it so that when i type in domain.com/user/1 the one gets pulled in as a variable and then can be used to get the correct database values. Right now the variable is set manually with domain.com/user . How do I setup the segments and then make get() that number. I'm working only with username url's as numbers so no, names just domai...

SQL Max Question

So I want to get the row with the most recent date, max(asofdate) but I am MySQL illiterate and can't seem to get it. It my head select * from Reports.InternalLoanExposureFlat where asofdate = max(asofdate) seems to make sense but the console seems to disagree with me. Thanks in advance. ...

How to join 2 tables & display them correctly?

http://img293.imageshack.us/img293/857/tablez.jpg Here is a picture of the 2 tables. The mybb_users table is the table that has the users that signed up for the forum. The mybb_userfields is the table that contain custom profile field data that they are able to customize & change in their profile. Now, all I want to do is display all ...

Simulating variable column names in sqlite

I want to store entries (a set of key=>value pairs) in a database, but the keys vary from entry to entry. I thought of storing with two tables, (1) of the keys for each entry and (2) of the values of specific keys for each entry, where entries share a common id field in both tables, but I am not sure how to pull entries as a key=>value ...

How to display a students rank out of hundred students using PHP & MySQL?

I'm trying to get the rank of a certain student out of a class of a hundred, I want to be able to display the students rank. I'm trying to get the rank of a student by grades and grade points. For example if student 1 has 2 A+ grades with a total of 10 points and student 2 has 3 B- grades with a total of 10 points student 1 will rank hi...

I want to ascend and decend MYSQL from a value in the database.

I want to ascend MYSQL from a value in the database. Hypothetically: database with table tbl_numbers column numbers has 10 values in it 1-10. I want to: order by numbers desc {from 8} LIMIT 3 it would show 8 7 6 instead of: order by numbers desc LIMIT 3 10 9 8 If this is possible what php and not mysql that's good too. --upda...

How to move a marker 100 meters with coordinates

I have 2 coordinates. Coordinate 1 is a 'person'. Coordinate 2 is a destination. How do I move coordinate 1 100 meters closer to coordinate 2? This would be used in a cron job, so only php and mysql included. For example: Person is at: 51.26667, 3.45417 Destination is: 51.575001, 4.83889 How would i calculate the new coordi...

Java - JDBC driver and MySQL database connection issues

Ok - I found the driver version that goes with the database.. however now I get the following. Got an exception! Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.ConnectException MESSAGE: Connection timed out: connect STACKTRACE: java.net.ConnectException: Conne...

MySQL - Is it possible to get all sub-items in a hierarchy?

I have looked at this: http://stackoverflow.com/questions/197362/select-products-where-the-category-belongs-to-any-category-in-the-hierarchy And it is talking about CTE, which doesn't exist in MySQL. I have structure like: category_id | parent_category_id | name I want to retrieve all the sub-categories ids of a given category_id. I...

Will my site be secure?

Hello all! I'm just about to release a website I've designed into the wild, but before I do, I would love some help determining whether I have made any silly security mistakes. Since I'm using shared hosting rather than dedicated, this is a very important concern. After much research and tutorial-reading I've done the following: All P...

Help with LEFT JOIN command in php & mysql

What I wanna do is replace ALL columns in the "subject" field & that has a "0" in "replyto" with the subject ( as long as it is 0) because when replying it leaves a "RE" thing which i dont like... so i just wanna replace it with the subject matching 0 How can I accomplish this?? $result = mysql_query(" SELECT * FROM mybb_posts ...

Why should i use 1 table instead of two?

I have two tables called (Up|Down)Vote, you can do BOTH upvote and downvote thus it isnt one table with a bool. People suggested i should use one table called votes and have a field called type. Why should i do this? I think writing the unique table name is easier then writing Vote then the extra where statement (type & upOrDownTypeBit)...

Creating dynamic where clauses in mysql

Is it possible to dynamically modify the where criteria based on what the user selects? I'm creating a form that has a few dropdowns. For example, given the query below, a client can search the database for properties based on price, neighorhood and type of property (i.e. condo, townhome, single family, etc...). However, there's also an ...

Reformatting the query

I have a table called sym_dis. select * from sym_dis gives +--------------+-----------------------------------+ | disease | symptom | +--------------+-----------------------------------+ | typhoid | headache | | typhoid | high fever | | typho...

How do I add to each row in MySQL?

We have a column that is a simple integer. We want to add to each row the value 10. How do we do it in sql for the MySQL database? Actually we have another column that needs to do the same thing, and it is a date. We need to add a month to the date. How to do that? ...

MySql N00b, problem with timestamp

There are some other questions where people have problems with timestamp being all zeros. I have checked them and this is not a duplicate. I declare a table like this: CREATE TABLE `my_db`.`my_table` ( `time_stamp` timestamp NOT NULL, `author` varchar() NOT NULL, `text` text NOT NULL, `md5` int(11) NOT NULL, PRIMARY KEY (`ti...

Pulling data from MySQL into Hadoop

I'm just getting started with learning Hadoop, and I'm wondering the following: suppose I have a bunch of large MySQL production tables that I want to analyze. It seems like I have to dump all the tables into text files, in order to bring them into the Hadoop filesystem -- is this correct, or is there some way that Hive or Pig or what...

Deleting all records of a table that are not referenced from another table

2 tables: items(id, ...) users(id, item_id, ...) How do you delete all records in items that are not referenced from users? ...

how to update data to gae localhost server from mysql ..

i follow this article : here to update data to gae localhost server from mysql. this is my str_loader.py is : class College(db.Model): cid = db.StringProperty(required=True) name = db.StringProperty(required=True) class MySQLLoader(bulkloader.Loader): def generate_records(self, filename): """Generates records from ...