Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Extract Data According To Preset Sequence... How?


wondering whether i can make this work...

first, i will make an array like this:

Quote:

$category_id[]="10,6,9,8,3";

then i wanna extract the information( category name, category id, and sub category into array and arrange them in the preset sequence in category_id[] above.

Quote:

$query="select * from category order by $category_id[] ";
$result="mysql_query($query) or die(mysql_error());

while ($row=mysql_fetch_assoc($result))
{
echo $row['category_id'];
echo $row['category_name'];
echo $row['subcategory'];
}

the output i wish to get is like this:

Quote:

1st result:
category id: 10
category name= the name of category 10
sub category=
sub 1 category 10
sub 2 category 10
sub 3 category 10

2nd result:
category id: 6
category name= the name of category 6
sub category=
sub 1 category 6
sub 2 category 6
sub 3 category 6

3rd result:
category id: 9
category name= the name of category 9
sub category=
sub 1 category 9
sub 2 category 9
sub 3 category 9

I'm confuse in the extraction info according to the preset sequence... can anyone please share some ideas? will this idea works?




View Complete Forum Thread with Replies

Related Forum Messages:
Inserting New Data Within A Structured Sequence
I'm trying to organize rows in a specific sequence. However, I also want the capability to insert new rows within that sequence and not simply append them to the end of the dataset as autosequencing would have you do. How is this accomplished?

View Replies !
Extract Data Into CSV
i have a batch file that moves my data between mysql tables. I would like also to create a csv file for that data? So if i move 5 records into a table it will also create a csv file
i would put csv code below insert statment?

INSERT INTO referral_authorization2 SELECT * FROM referral_authorization;

View Replies !
Data Extract
I have a table with the schema below and I want the output as below show also.

+-----------+----------------------+------+-----+
| Field | Type | Null | Key |
+-----------+----------------------+------+-----+
| ID | int(11) | | PRI |
| ENTRYDATE | datetime | | |
| SOURCE | varchar(13) | | |
| NWKID | smallint(2) | | |
| FLAG | tinyint(2) | | |
+-----------+----------------------+------+-----+

There are only 3 types of nwkid (1,2,3)
The output I'm looking for should look something like this
where nwkd1 is a count of nwkid = 1 and
nwkd2 is a count of nwkid = 2 and
nwkd3 is a count of nwkid = 3 and they are grouped by a date range,
between date_someday and date_someotherday

+-------+-------+-------+------------+
| nwkd1 | nwkd2 | nwkd3 | entrydate |
+-------+-------+-------+------------+
| 23 | 22 | 25 | 2007-03-27 |
| 12 | 14 | 13 | 2007-03-28 |
| 33 | 32 | 34 | 2007-03-29 |
+-------+-------+-------+------------+

How do I achieve this?

View Replies !
Extract Data
I have a database and I want to extract data from column two row two. I cannot use matching. I would like to use something like this: select col2 from mytable where row=2; but I know this does not work. I cannot use something like this: select col2 from mytable where col1 like 'such_and_such';
I just simply need to be able to select col2 row2 and extract the data. Is there a way to do this?

View Replies !
How To Extract Only The Starting Data?
I have a problem with my Mysql data. I have 2,95,67,456 lines of data which is too much and if I run this in MYSQL front-end it is telling "OUT OF MEMORY". Any way with my collegues system I have got the runned data and I have copied it to my Frontend, now it works. But my problem is if I am extracting particular data from that it is telling "ACCESS VIOLATION" so I have decided to extract only data from the first 1,00,000 lines, my question is"Is there any command in Mysql to extract data starting from 0 and ending at 1,00,000"if so can anyone tell me about that as soon as possible.

I have used SELECT ***** FROM **** WHERE **** LIKE *****(If we give this it will select the mentioned data from the whole database)

But, I want only the data from the first 1,00,000 lines

View Replies !
Extract Partial Data
On my site I display a list of 10 articles on a page. I show 10 titles plus the first 250 characters of each article. At the moment with my MySQL statement I bring all the data from the database and parse it with PHP to show the partial content text. This seems very slow to me especially if the articles are big.
If I truncate the data I bring from the database will that be a faster way to bring across the data?
What would be the best way to do this?
So far I've tried..Code:

SELECT id,title,SUBSTRING(article, 0, 250) as article,showdate from articles ORDER BY showdate DESC Limit 0,10

But that doesnt bring anything across, 'article' seems to be empty.

View Replies !
Extract Data Using Joins
I am at the point in testing where I need to create new tables to keep things 'clean.' I have a users table that has userid in it, auto incrementing as you would expect. Now I want to add another table to deal with some other things. I have seen how to extract data using joins, but now I want to know how I can relate this new table with the users one(and put the userid into the new table)

View Replies !
Extract Data From Notepad
Does anybody knows how to extract data from notepad the save it automatically to the database and automatically delete duplicate data.

for example data that must be extracted from the notepad ...

View Replies !
Extract Data And Create Database:
I'm working with this webpage (PHP/MySQL solution) locally and I'd just
want to ask if there was a program that could extract all the tables and
data from this local database (fx. to an SQL string) which I then could
use to recreate the database on the server? I reckon I can't just copy
the database, or?

View Replies !
Extract Data And Create Database
I'm working with this webpage (PHP/MySQL solution) locally and I'd just
want to ask if there was a program that could extract all the tables and
data from this local database (fx. to an SQL string) which I then could
use to recreate the database on the server? I reckon I can't just copy
the database, or?

View Replies !
Most Efficient Way To Extract Limited Data
I am currently using the following code, is it the most efficient way to extract and sort the 6 items from the database. The database currently holds over 2,500,000 rows and I want to extract the data as efficiently and quickly as possible. Code:

View Replies !
How Do I Extract All My Text Data Input From A Php Forum?
I manage a small website using phpbb on a Solaris platform, using mysql 4.x. After being repeatedly hacked, I'd like to migrate to a less singled out forum bb, but without losing my data--most of which is in Chinese characters (so doing string searches is definitely out).

I have direct file access via ftp to the server, and i've also downloaded the corrupted files, only two of which have been modified by the hacker, namely,

phpbb_config.ISD
phpbb_forums.ISD

Unfortunately, the last previous backup the hosting company performed was some 8 months before...

View Replies !
Extract 5 Digit Column Data Into Another Column
i would like to make an update on my tables, which extract out the zip code from an address column into another new column call zipcode... coz the previous design of the table doesn't have this column.

View Replies !
Disrupted Sequence
Another brainteaser:

CREATE TABLE IF NOT EXISTS `test` (
`id` INT(11) unsigned NOT NULL auto_increment,
`cid` VARCHAR(10) NOT NULL,
`item` VARCHAR(10) NOT NULL,
`val` INT(11) NOT NULL,
`dt` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1

In the above example table I need to find the first 5 highest values of val that break the sequential set of values. In other words: say I have values 49,48,45,44,43,40,39,37,36,34 of val in my table, with 49 being the highest value of val (need to sorted first, because values may randomly be dispersed in my table), then I want to get 47,46,42,41,38 as the query result.

View Replies !
Create A Sequence?
I am creating an application that will contain three tables that need to share the same sequence. Upon digging through the docs, I do not see how I could do this.

Could someone give me some guidance into this?

Also, As I read the docs, when I am creating tables, there is something about an InnoDB? Sorry to be confused, but I am not sure how to begin creating my database, nor tables without this knowledge.

View Replies !
Sequence Substitute
I have a problem about create sequence number which can be reset after MAXVALUE has been assigned. In the older version of mysql i can use "create sequence", but in the recent version i can't do that anymore. All i know in mysql ver 5 is "Auto_increment" which cannot be reset number without delete or truncate table.

View Replies !
CREATE SEQUENCE ?
Tracing some examples in a book from Apress,
for some reason they go for Oracle in this book -
not my cup of tea, especially not when I am sitting on
a vista-terminal. Enough of my complaing.

How do I create a sequence in mysql ?

This is the example I am stuck with:

CREATE SEQUENCE SEQ_ID_GEN INCREMENT BY 1 START WITH 100 MINVALUE 1 CACHE 50 ;

How do I write that sentence in mysql ?

View Replies !
Sequence Creation
I am not able to create a sequence in MySql.. But its giving error.

Can any one pls tell me how can i do that?

View Replies !
Sequence Generation
I was wondering if there was something close to CREATE SEQUENCE in MaxDB for standard MySQL.

I'm thinking of just doing a table/stored procedure and calling it a day, but was wondering if MySQL had some other alternative.

View Replies !
What Collation Sequence?
I've just transferred a small PHP/MySQL application from a Firepages phpdev5 install to an XAMPP install, so I've got new versions of everything. I used phpMyAdmin to export and import the tables of the database. When recreating the database on my new install I selected the default collation (latin1_general_ci) but my application is now displaying ? in place of a number of characters so I guess I got it wrong. I can't see where in the old phpMyAdmin (2.3.0-rc3) to determine what collation the database uses.

View Replies !
Identity, Sequence, Serial
Does MySQL offer capability for any of the following?
- IDENTITY
- SEQUENCE
- SERIAL
Or is AUTO_INCREMENT the catch-all for the functionality of all of the above? I ask because I'm looking into Java EJB3 which describes support for any of the above (as well as AUTO_INCREMENT, so I'm not out of luck completely).

View Replies !
Re-arrange Primary Key Sequence
i am facing a problem with my application when someone deletes a record and hence its key disappears breaking the sequence e.g

1 - entry
2 - entry
(3 - deleted no mere here)
4 - entry
5 - entry


When key is not there my AJAX application fails to run properly due to not finding next id. Is there any method to re-arrange primary key values to a proper sequence when one or more numbers are missing?so that i will write a query and whenever user deletes an item i will re-arrange the primary key sequence automatically

View Replies !
Selcting Date Sequence
I am trying to return a set or rows that represent all of the days between two dates. For example, I want to select all the days between December 25th, 2005 and January 5th of 2006, and i am looking for it to return (shown here in CSV)
2005,12,25
2005,12,26
2005,12,27
2005,12,28
2005,12,29
2005,12,30
2005,12,31
2006,01,01
2006,01,02
2006,01,03
2006,01,04
2006,01,05

So, for any date, i want to select all the days in between. Any ideas?

View Replies !
Order By An (out Of Sequence) Set Of Numbers
I'm having a problem as follows:

here is a an example table (tbl_test):

id | value
----------------
1 | hello
2 | hi
1 | bye
4 | cya
where the value field is variable.

and i want to select them so they are listed as follows:

id | value
----------------
2 | hi
1 | bye
1 | hello
4 | cya

is it possible to order by and array - something like:
SELECT * FROM tbl_test WHERE 1 ORDER BY id (2,1,4)

View Replies !
How To Create A Sequence In MySQL
I am not able to create a sequence in MYSQL 5.0
Want help on creating the same.

Basically, what I am looking for is, that I should get a number greater that the last one on every call to this sequence.

In Oracle, one can simply write something like:-
CREATE SEQUENCE seq_ordermaster
increment by 1 start with 1
maxvalue 999999minvalue 1
nocache
Nocycle;
And while calling, one can use it by selecting seq_ordermaster.nextval from DUAL

Considering the fact that there is no DUAL table in MySQL, how can One write such a sequence and also, how one can get the next value on each select statement?

View Replies !
Mysql Execution Sequence
I need to retrieve the last value from a column in a mysql table, perform some actions on it, then add 1 to the original value and store a new entry.

I am worried that if multiple users access the database at the same time I will end up with duplicated 'new values'. Does mysql complete execution of a script before it allows access to another user or do I need to 'lock' the table in some way while the script executes?

View Replies !
Find The Number Of A Row In A Sequence
MySQL Code:
SELECT * FROM comments WHERE id=12345 ORDER BY rating

Is there a way to determine the position that this rows appears in the sequence?

Eg, so I can print out:

"This site is rated position x out of y"

View Replies !
EXTRACT
SELECT EXTRACT(YEAR_MONTH FROM '1999-07-02 01:02:03');

What could cause this query to return something like this:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'YEAR_MONTH FROM '1999-07-02 01:02:03' )
LIMIT 0, 30' at line 1

View Replies !
Bulk Insert Of New Records In Sequence
I am looking to create a querty that searches for the max value a field
called listnum in a table called tbl_listing and then interests 25 new
records with listnum's starting 1 higher then the max value.

ie if the highest listnum is 1000 it should insert new records with a
listnum of 1001-1024. All the other fields in the table can be blank.

Is there a simple (or not so simple) query that I can run to do this?

View Replies !
How To Generate Sequence Values During Query
I have query like below:

SELECT part_no,part_nm,qty FROM tb_stok_out ORDER BY part_no

as result:

part_no part_nm qty

aaa asdfd 3
abab sdfsdf 4
abab adfdf 5

Is it possible in mysql to generate sequence number using query, so the result will be like below :

1 aaa asdfd 3
2 abab sdfsdf 4
3 abab adfdf 5
... etc

View Replies !
Change The Sequence Of Column In Table
I am using MySql Query Browser I want to change the Sequence of Column in data table
e.g.

Before : table sequence is (UserID, Name, BOD)
After : table sequence is (User ID, BOD, Name)

How can I do that?

View Replies !
Create Sequence Syntex Errors Out
I installed mysql 5 and trying to setup database. Somehow it can't create sequence. it throws generic 'check the manual that corresponds to your mysql server version......'.

I have tried just about anything nothing works.
Also tried to reinstall mysql few times--same thing.
Also tried to go through mysql 5 manual nothing is in there for sequence.
Or sequence is not supported with mysql version i have?

View Replies !
Extract, Transform
We have an old legacy database at my company called CIMPRO, running on
a SCO UNIX box. We're trying to find a way to connect to the CIMPRO
database, grab the data, and send it to a Mysql database.
I've been able to successfully connect to the database using PHP and
ODBC to view the data in the tables.
i'd like to find a way to run a Linux tool or script to connect to the
database, do an initial copy of the table structure from the legacy
database to Mysql (on the linux box) and then copy selected data.
If that is doable I'd also like to be able to refresh the table data
periodically (e.g., cron job) either by deleting and reimporting or by
checking to see what has changed.

View Replies !
Extract And Compare
I was requested to do a report which consists in:
Report total sales (for example) in month: XX
Now, The user has 2 options:
- Actual month (default)
- A month choosen from (month name? or month number?)
I'd like you to help me in these 2 steps...
1. How to get records which were "saved" in actual month ?
2. How to compare and make queries if user selects month name or month number ?

View Replies !
Extract Specified Part
In one of my table, I have a date type field in format 0000-00-00, in my php syntax, how can I extract the year part only? i.e. only 2005 from 2005-07-08. I searched the help from mysql reference, but too tired for me now

View Replies !
Extract First Sentence
I have a field called "body" which contains a whole bunch of text (complete sentences). I would write a query to pull this part of the DB but I ONLY want to show the first sentence! How can I do so?

View Replies !
Extract Function
Is there any way to adapt the EXTRACT function to work on multiples of minutes, hours etc.
In the example below I would like to count the distinct opid's in an hour for a 2 min or a 5 min interval.
I do not want to use a while loop to make multiple queries.
Code:
SELECT EXTRACT(minute FROM arrived) AS themin, count(DISTINCT(opid)) AS op_count
FROM `chatEntries`
WHERE `arrived` >= '2008-04-01 00:00:00' AND arrived <= '2008-04-01 23:59:59'
GROUP BY themin

View Replies !
Extract By Date
I'm trying to make my script show Live Dates that haven't happened yet from my DB.
But the syntax is wrong: DATE_FORMAT(date,'%a, %b %D, %Y') AS date WHERE date >= CURDATE()
How should this be done? Code:

View Replies !
How To Extract Id Of Inserted Row?
I wonder how can I extract id of row that was just inserted into table? For example, PHP script inserts info about uploaded image into database and id column is "Auto Inc". How can I exctract value of this column?

View Replies !
Extract Date
I have this table in the Db MySQL:

Code:
DATE|ID_M|TOT
2007-09-01|1|1720,5
2007-09-01|2|1294,9
2007-09-02|1|1689,25
2007-09-02|2|1364,85
2007-09-03|1|1627,11
2007-09-03|2|1388,2
2007-09-04|1|2431,95
2007-09-04|2|467,95
2007-09-05|1|2011,9
2007-09-05|2|630,55
I need with query SQL this result:

Code:
DATE|TOT_1|TOT_2| TOT_1+TOT_2
2007-09-01|1720,5|1294,9| 3015,4
2007-09-02|1689,25|1364,85| 3054,1

View Replies !
Max Sequence Number In Claim Transaction Table
have a table that contains a transactional history showing how a claim amount has changed over time. Each time the claim amount is updated, a new claim sequence number is used.

The fields I have are Claim Number(CLMKYT), Claim Sequence(CLMSQT), Claim Amount(£)(OUTSTT) and Date the claim was entered/updated (EFFDTT)

I want to pull out the latest (most recent) claim amount for each claim as at any particular date.

I have the below query which I think almost gets me there, but not quite!

Code: .....

View Replies !
Generated Sequence # Based Upon Content Of Row Being Inserted
I have a table -

CREATE TABLE `sample` (
`Id` smallint(6) NOT NULL auto_increment,
`division` varchar(5) NOT NULL,
`secion` varchar(5) NOT NULL,
`div_sect_seq` smallint(6) NOT NULL default '1',
PRIMARY KEY (`Id`)
);

I'd like to write the insert statement that would generate the next div_sect_seq number based upon the value being inserted into the table.

Let's say that the table contains:

|--id--|-division-|-section-|-div_sect_seq-|
| 1 | SC | XX | 000001 |
| 2 | SC | YY | 000001 |
| 3 | SC | XX | 000002 |

I'd like to insert a row for divsion = 'SC' and section = 'XX' with the next div_sect_seq (which would be the max value of div_sec_seq + 1 on the sample table for the division and section) which should be the value of 000003.

View Replies !
Primary Key Field: Varchar(32) Versus Sequence
I got in the habit of coding primary key fields as varchar(32) that was generated by an md5() since it was a public site and I wanted to avoid people guessing record numbers (for other reasons).

Is there a performance problem with doing that?

If so, how do you tackle the same concern?

View Replies !
Ordering By Sequence Field With Empty Values
I have a sequence field in my db table that I'm using to order a list. I'm trying to ORDER BY this field, but it puts the empty values before 1 such as
empty, empty, 1, 2, 3, 4
instead of
1, 2, 3, 4, empty, empty, empty
How can I fix this?



View Replies !
Index On Long Column And Auto Sequence In Mysql
How do we create index on long columns in Mysql? we want to store the timestamp component of the data field in a long data type and be able to index on it.

View Replies !
Extract Meta-informations
I'm trying to extract meta-information from MYSQL-Database in order to
do a manual replication of tables into another database.
I would like to extract the information which table has which primary
key etc.Is there another way then "show tables" and "describe" to obtain this
information? Isn't this information stored in some system table like
other systems (I'm familiar with Oracle, DB2 and SQL-Server) do ?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved