The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “1Win

MYSQL ordered table

komrad66

New Member
affiliate
Hello all,

I'd like to know if there is a way to insert into a MYSQL table data in an ordered way?
Right now as a workaround I've literally made a table of questions with questionID as primary key, nextQuestion and prevQuestion pointing to other questionIDs. Basically I've made a two way linked list from scratch. Is there anything built into MYSQL that implements this?

Thanks in advance.
 
How about using a "priority" column so you can easily switch entries around and allow you to order the questions quickly within the SQL SELECT statement?

ChrisB.
 
You are clearly not making the best use of a relational database. Relational databases have built in indexes that let you quickly list records ordered by certain field.
You have to:
1) Create an indexed field . The primary key is automatically indexed. If you want to sort using a different field than you have to create an index using the keyword "index"
2) Then try a query like
select * from employees order by age

If you want descending order
select * from employees order by age desc
 
You could create a column called 'sequence_id' which will be an integer. Then you can give all the rows in the table a sequence of whatever you want so when you write your query to retrieve the rows just add 'ORDER BY Sequence_ID to the end.
 
Hi, how can you connect to database or the relation of your database?..D

Create a function like this:

function DBConnect()
{
$dbh=mysql_connect ("localhost", "USER NAME", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("DATABASE NAME");
}

Swap 'localhost' for an IP address if the DB is located elsewhere.

Call it like this.

DBConnect();

If you place the DBConnect function in an inc file and then use the 'include' command to refer to it in your pages then if you change the DB creds you only have to change it in one place.
 
Last edited by a moderator:
you can ordered the sequence of data in the column by alphabatically as ascending or decending order you have need to use the order by desc or asec
 
you can dictated the sequence of data in the column by alphabatically as ascending or decending order you have want to apply the order by desc or asec.
 
banners
Back