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.





Pull All Records


if it were possible to write a statement in SQL where one could select several fields from a table and then limit the records returned by only displaying those where, say, FieldA (a varchar) contains a given short string which could be only a part of the field's contents. As long as a record has this short string in Field A, it should be included in the resulting set of records.Something like this:

SELECT FieldA, FieldB, FieldC
FROM TABLE Table1
WHERE FieldA *contains string*

Is there anything in SQL that could examine the contents of a field for a partial string, and then return the records that have that partial string in that field?




View Complete Forum Thread with Replies

Related Forum Messages:
Pull The Last 10 Records From A Transactions From A Table
I'm trying to pull the last 10 records from a transactions from a table using this query:

SELECT * FROM transactions ORDER BY timestamp DESC LIMIT 10

But I want to display the rows in ascending order by timestamp. I can't get the subquery below to work and not sure why:

SELECT *
FROM (SELECT *
FROM transactions
ORDER BY timestamp DESC
LIMIT 10)
ORDER BY timestamp ASC;

View Replies !
Pull All Usernames
Say I want to pull all usernames beginning with the letter A. How can I do so?

View Replies !
Multiple DB Pull
Lets say there is a database of special users and a database of favorite movies

SPECIAL USERS (username)
bob
jim

FAVORITES (username - movie_title)
bob - movie 1
kim - movie 3
jim - movie 1
larry - movie 2
jane - movie 2

How would I write a query that lists the most popular movies of special users without explicitly doing:

SELECT * FROM FAVORITES WHERE username = 'bob' or username = 'jim' GROUP BY movie_title

I want something like this:

SELECT * FROM FAVORITES WHERE username = [all the usernames from the SPECIAL USERS DB] GROUP BY movie_title

View Replies !
Mysql Pull
I got this in my mysql databe table.
a:1:{i:0;O:19:"test_Enclosure":4:{s:4:"link";s:36:"http://grabber/v/CAcpLiw4qt4.swf";s:4:"type";s:29:"application/x-shockwave-flash";s:6:"length";N;s:10:"javascript";s:2:"js";}}

I want to pull out only the
http://grabber/v/CAcpLiw4qt4.swf part?

View Replies !
Can Input Japanese, Can't Pull It Out
I figured out how to store Japanese characters by setting the collation of a particular field to utf8_bin. I can input Japanese characters, and I can see them just fine under PHPMyAdmin.

The problem is that when I execute a query and print them to a web page, all I get is question marks instead of Japanese characters. This is while using the same browser that allows PHPmyAdmin to display the characters correctly.

I added the following metadata to the <head> portion of the document but it didn't help:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

View Replies !
Populate A Pull Down Menu From Db
how do I populate a pull down menu from a MySQL table?
Using PHP/MySQL 4.0

Have table1 with names and ID and tableb with ID and statistical info.wnt to be able to scroll names and have users able to click on the name to follow a link to a page created using tableb data for each name listed.


Table examples:
tablea
ID l Name
---------------------
1 Person, Joe
2 Smith, Joe


tableb
ID l units l margin
--------------------------------
1 5023 123
2 2536 72

View Replies !
Code To Pull Amount
I'm certain there is a function to do this but I forget what it is...
Say I am pulling values from the database, but I only want to pull like the first 10 chars of the value.. how do I do that?

View Replies !
Pull Hosting Plans
I am currently creating a web hosting website for a client of mine, for the packages and the order process we are using a script called "Auto-Host (http://www.idevspot.com/AutoHost.php)", which stores all the hosting plans into a mysql database.

This is a great script and it does exactly what we want it too, the only thing missing is it doesnt create a page where people can view the hosting plans and click a sign-up button. Can someone please give me guidance on how i can get a page with all the hosting plans on please?, alternatively i am willing to pay somebody for doing this on my behalf

View Replies !
Pull Related Info Using Subqueries
I'm creating a tool to browse a database of movie listings. The browser
pulls up 25 results at a time, and you can page through them using 'Next'
and 'Prev' tools. Pretty basic stuff.

Here are my tables:
movies
directors
comments
movies_directors
movies_comments
etc...
(primary key is movies.id)

But here's where I'm stuck: for each film, I need to pull the movie info in
'movies', plus any related data from other tables, like this:

The Lord of the Rings | Peter Jackson | 3 comments
Episode II | George Lucas | 0 comments
Indiana Jones | Steven Spielberg | 15 comments

I seem to run into problems when I try to join info from all of these
related tables. If there's a match, great. But, if not (like a movie with no
comments), the movie is excluded from the result set.

I've tried all sorts of SQL queries to make this work, but nothing seems to
do the trick.

SO, HERE'S MY QUESTION, IS THERE ANY WAY TO DO THIS QUERY WITHOUT
SUBQUERIES/MYSQL 4.0? Or would the best approach be to use PHP to do all the
subquery lookups?

View Replies !
Pull Similar Data From Two Tables
I need a query to search two seperate tables for similar data and return them in one result.

I know you can do multiple select statements in one query but I dont know how to exactly organize them into one result. Does anyone know how to accomplish this.

View Replies !
Result Pull And Rating Sort
I have two databases. What I would like to happen is when I have a summary of products, I would like the query to pull the info from the product table and based on the id from that table cross reference with the reviews for that particular product and calculates all the reviews for that product into a single percentage. So when I access the assoc array from PHP I would like to see : Array(Array(['id'] => '2', ['prod_name'] => 'gummy bears', ['rating'] => '72'), Array(['id'] => '57', ['prod_name'] => 'socks', ['rating'] => '52')).

View Replies !
How To Pull Data From Multiple Tables
I have a db, with several tables in it, I have now reached to the point where I need to pull data from several tables. What is the best way to do this?

Should I put a column in each table, and then insert a unique key in all of them at the time the record(row) is being created? If this is the way to do it, when I am putting the unique key in each table would I just do an insert in each of the tables?

View Replies !
Pull Data From Multiple Tables
Can you pull data from 2 tables in the same database onto the same page? What about more than 2 tables?

Here is my dilema: I currently have a database with 1 table, and a ton of rows. The information is property information, and each property has multiple empty suites. As of now, I have columns for Building Name, Address, and then columns for Unit Type A (for the first unit), Rent A, Type B, Rent B, etc....

I was wondering if I would be able to put the listings we have into thier own property table, and then one bigger table of all the properties individual information. Keep in mind I need to call all tables together on my portfolio pages, so I would be connecting to quite a few tables at once.

Or my other option I was thinking about was to just have 2 tables: 1 Buildings info, and 1 units info.

Which of these would you do, or how would you organize this data.

View Replies !
Regular Expression :: Pull 3 Or 4 Digit Numbers
I would like to pull all the model number from my products table that are strictly only a 3 or 4 digit number ie:

034 or 3542 or 0243 or 934 etc

Can someone advise me on how to construct a regular expression to give me the data I need?I have tried the following but it wasnt 100% accurate:

Code:

products_model REGEXP "[[:<:]][0-9][0-9][0-9][0-9][[:>:]]" or products_model REGEXP "[[:<:]][0-9][0-9][0-9][[:>:]]"

View Replies !
Pull Data From Ibdata And Ib_logfile Files
I lost the data in a scheme and the only logs I have are the ibdata and ib_logfile files. Is there anyway to parse the data from these files to rebuild my data set?

View Replies !
Pull Info From One Database To Save In A Session To Push To A Different DB
I'm building a dynamic site that has 3 data bases. One DB contains all
of my store info ID#, Name, Address, Phone. Another DB contains member
info ID, Name, address, email,phone,etc...
The 3rd DB Tracks when a user logs in and logs out at a store. This DB
has the following columns Store ID, Member ID, log in time,log out
time, time in store.

The stores log in in the morning that starts a session-I need the
session to pull the store's info ID#, Name,etc... so when a user logs
in, in the store. The login page inserts the store ID, Store name, and
user ID into the 3rd DB.

There are a lot of stores how do I get the store variables to be
inserted into the DB?

View Replies !
Pull Data From 2 Database Tables Into 1 Table On My Site.
I got 2 tables: a dev_tasks and a task_history table. The task table has to record information about the task I am working on AND the history table is for the task history logs. I am trying to display info from both tables into 1 table on my site.

Most of the info will come from the dev_tasks table BUT i want to dedicate on column of the displayed info for the latest log made to the task_history table.

The common column to both tables is the 'taskid' column.

What would the query look like to pull the info from both tables, knowing that the taskid is common to both and that I want to display the last log per tasks from the task_history table?

View Replies !
Trying To Pull Id, Count And Title But Lose Rows When I Add Extra Join
i'm trying to extract some information from my database, the query being

PHP

SELECT grps_c.catid, grps_c.title, COUNT(grps.groupid) AS COUNT
            FROM grps
            RIGHT JOIN grps_category grps_c ON (grps_c.catid = grps.catid)
            GROUP BY grps_c.catid
            ORDER BY grps_c.title

which works fine. however some of the groups (grps.groupid) are hidden and i don't want to count them, so my thinking was add

PHP

LEFT JOIN grps_setting grps_s ON (grps_s.groupid = grps.groupid AND grps_s.hidden_group != &#391;')

however adding that removes the rows that have a 'count' or NULL or Zero.

View Replies !
Creat Mysql In Unix And Pull/post Data From A WindowsXP Machine With A UserDSN?
Can I creat mysql in Unix and pull/post data from a windowsXP machine with a UserDSN?

Is there an Administrative Tool (User DSN) that I can utilize to pull/post data to a Unix account without having to through the long process of "FTP" and "XTerm windows" ?

View Replies !
Selecting Records Belonging To Multiple Records Through Join Table
I have is 3 tables, 'categories', 'levels' and 'categories_levels', the 'categories_levels' table is a join table, with the `id`, `category_id` and `level_id` fields. Categories can belong to many different levels, so records in the join table might look like this (assuming that the category has an ID of 5)

id, category_id, level_id
1, 5, 1
2, 5, 2
3, 5, 3

So you can see that category 5 belongs to 3 different levels (1, 2, and 3).

On a web page, I've got a multiple select box, which allows a user to filter the categories depending on which levels they belong to. What I need a query to do is use that join table to find all categories which belong to the selected levels. Now for the tricky bit. Only the categories which belong to every single selected level should be displayed. So in the example above, if I select level 1, then category 5 will be displayed, but if I select levels 1 and 4, then category 5 should not be displayed, because although it does belong to level 1, it doesn't belong to level 4 as well.

View Replies !
Counting Records From Subsets Of Records Returned From Query
I am trying to figure out how to count a subset of the records returned from a query. I have a query that returns records that fit the criteria ....

View Replies !
Selecting From 1 Table Only Records That Match Multiple Records In Another
I am having trouble writing an SQL statement to select all the records in Table-A that have multiple corresponding records in Table-B that meet a requirement.

Example: .....

View Replies !
All Records From Table A - All Records From Table B - Join Alike Records
I am by no means a SQl Jedi as will be apparent by my question, but I
can usually figure out a select statement on my own. I have one today
though that really has me stumped. I am working in MySQlL 5.

In My first select statement I get all my records from Table B
SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
`table_B`.`Qty`,
`table_B`.`Calc` as calculated
FROM
`table_A`
Inner Join `table_B` ON `req_itemlist`.`ITEM` = `table_B`.`ItemID`

In my second statement I get my records that match in this case phase
401 in Table B and all my Table A records for phase 401.

SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
`table_B`.`Qty`,
`table_B`.`Calc` as calculated
FROM
`table_A`

Left Outer Join `table_B` ON `req_itemlist`.`ITEM` = `table_B`.`ItemID`
Where
table_A.PHASE In ('401' )

Now I need to combine the Data of both recordsets. I need EVERYTHING in
Table B, but I also need All Table A records that match the phase
selection....

Can I write this one query or do I need to use a Temp table?

View Replies !
Count Related Records, But Show Records With NO Related Records Also
cl_items
========
it_id (pk)
it_ownerid
it_name

cl_offers
========
off_id (pk)
off_itid (fk) -> to it_id
off_whoid

My query needs to output ALL of the records in cl_items AND still show how many offers are on each item (from cl_offers)

I can't get what I want through the GROUP BY because I want to show the records in cl_items which DO NOT have any offers on them yet also.

Is there any way to do this with mysql only?

View Replies !
Delete Records That Have No Related Records In Other Table
How do I delete all records in a table that have no related records in another table? I tried this:

delete from t1 where t1.id=t2.id and count(t2.id)=0;

but it says "Unknown table 't2' in where clause". What's wrong?

View Replies !
Delete Records Without Matching Records
I have a one to many relationship in my database. I would like to delete records in one table if there are no matching records in another table.

View Replies !
Records
I have a mysql database running on Mysql version 3.23.53 on a Red Hat
Linux 7.2. In the database there is a single table with over 150,000
records. Unfortunately, the performance of that table is very poor,
comparing to other tables in the same database.

View Replies !
10.000.000 Records
I've got some experience building PHP/MySQL websites, but the databases in these websites never contained more than a couple of thousand records. Now I've been asked to build a website with a database containing a table with roughly 10 million records.This amount of records gives me the creeps, to tell you the truth.
It's simple records, containing just 2 columns. The only thing a script would have to do is check wether a code is in the database or not.
Can I use standard PHP scripting methods and SQL queries, or does this amount of records demand a totally different approach? I can imagine an application getting very slow when it has to work with a huge recordset like this. What do I have to consider before I decide to build this site (or not)?

View Replies !
Certain Records
Code:

insert into users (username, password, email) select user , ID, email from selex.empleados_selex

but i want to copy only the records where its status is "working"

something like:

insert into users (username, password, email) select user , ID, email from selex.empleados_selex WHERE status =´working`

View Replies !
Records 1 To 10, 10 To 20 Etc
im not sure how to do this or what to search for so any help would be great.
basically if i do a (select * from table) how do i get only the fiorst ten matches like records 1 to 10 then like on another page id have records 10 to 20. i thought i coudld use limit but when i do say

SELECT *
FROM `sale`
LIMIT 2 , 4

i get 4 results back instead of what i thought would have been results ows 2 to 4

View Replies !
Pf Records
Is it possible to specify the limit of records that can be entered in the table.

View Replies !
Get Records
I have one table (members) and a linked table (payments) and I trying to retrieve all the records in the members table that don't have a record in the payments table.The payments table is linked to the members table by memberId. Does anyone know how I would compare the two tables and bring back only the members that don't have a record in the payments table?

View Replies !
Records
I want to extract those values whose modificatio dates are few days older using the following sql
[SQL]
select status from note where mdate<=date_add(date('Y-m-d'),interval -2 day) and status='Selected' and id=$r[0];
[/SQL]
but the comparison 'mdate<=date_add(date('Y-m-d'),interval -2 day)' doing nothing. I have checked it in db. There is no error too. How to correct that?

View Replies !
40 Records
This is to gather a sample from the database.
I need to select 40 consecutive records every 1001st record.
So I would need records 1001-1040
and
records 2002-2041
and so on.
Anyone have a clue on how to write the query for this?

View Replies !
To Many Records
This query is getting me rows which dont = $cid can anyone tell me why? =x
Code:

"SELECT event.eventName, event.eventMonth, event.eventYear, exhibitor.standNum
FROM event, exhibitor
WHERE exhibitor.companyID = event.companyID AND exhibitor.companyID = '$cid'"

View Replies !
Records That Are Only From 3 Pm To 6 Pm
I have a field in my table called time which is a datetime field.

The format of the data is like these below:
2006-07-12 17:55:19
2006-07-11 16:31:34
......

I would like to get every records that are only from 3 pm to 6 pm. Is there any query where I can check for the hour of a datetime field?

View Replies !
Add Records (bug)
when a record is added, it adds 2 records instead of one. Code:

View Replies !
How To Get First And Last Records
i want to get the first record and last record using a single query?

is it possible?

View Replies !
Can't See Old Records
I really don't know much about mysql.
We have an hardware device performing bandwidht management which
we didn't even know it is using mysql until it was broken down.

After we solved the problem, we saw that the operationg system running in the device is linux (and old version) and the database is mysql.

The problem is that we can't see the old data eventhough when I
view the binary ISD file I can see the whole data including the olds.
But the management program doesn't show the old data. When I reenter new definitions from the management program, I can see that they are written into the ISD files. ISD files contains both old and new records but I can see the only new files.

Does that mean the index files are curropted?
If so, How can I recreate indexes or recover them?

View Replies !
Top 5 Records - ASP
I have an ASP application talking to a MySQL database. All works fine but:

1) I can't figure out how to select just the latest 5 records in a table.

2) SELECT LAST_INSERT_ID() doesn't work, it just returns 0.

3) I need to select the 'recordid' (held in the first field and is the PK) of the latest record.

View Replies !
No Records In DB
I connected to the DB like this:
Set rsP1000 = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT [G2P] FROM tblClients WHERE ClientID = '" & strID & "' AND GTime2 ='10:00a'"
rsP1000.Open strSQL, adoCon

I was wondering if the connection does not return any results, how do I display nothing. It keeps failing out because there is no record.

View Replies !
Searching For Records
eg search for records having same email address

select txtemail,count(txtemail) from `tbl_user` GROUP BY txtemail
having COUNT(txtemail)>1;

and it works, is that the best way?

View Replies !
Duplicating Records...
I have looked long n hard at the Insert Select as being the answer to my
need to create duplicate records. (Purpose is basically to allow someone to
create a duplicate of an existing email template then modify it). I have
tried all sorts of variations on:

INSERT INTO emaillist SELECT * FROM emaillist WHERE emailid = #url.emailid#
(inc trying IGNORE) but of course this throws an error over duplicate keys.

All I want to do is to take Record A, duplicate it and have a new key
assigned to it (the key is an autonumber field).

View Replies !
Last N Records By Some_id
Here is a problem I've encountered a few times lately:

Given

CREATE TABLE foo(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
some_id INT NOT NULL,
ts TIMESTAMP NOT NULL
);

find the last (ordered by ts) N id's for each some_id, with N > 1.

Is this possible in "pure" (i.e. without application code) MySQL 4.1.x?

View Replies !
Orphan Records
Given this setup:

inventory.itemID

item.itemID
item.description

I want a list of item descriptions which do NOT have an inventory
record. Any ideas?I did this before in MS Access as I recall by making
a query of things with inventory only then excluding those but I can't
even recall how to do that now. I'm working with php/mysql now and had
some luck generating aql with Access but not for this one.

View Replies !
Duplicate Records
mysql> select id, student_first_name, student_last_name, email,
application_date, modification_date, unique_key from student where id
in (7268, 862);
+------+--------------------+-------------------+----------------------------+---------------------+---------------------+------------------+
| id | student_first_name | student_last_name | email
| application_date | modification_date | unique_key |
+------+--------------------+-------------------+----------------------------+---------------------+---------------------+------------------+
| 862 | Phil | Powell | phil@blah.com |
2006-02-27 00:00:00 | 2006-02-27 00:00:00 | dF0WByrCP0vACftA |
| 7268 | Phil | Powell | phil@blah.com |
2006-02-27 00:00:00 | 2006-02-27 00:00:00 | dF0WByrCP0vACftA |
+------+--------------------+-------------------+----------------------------+---------------------+---------------------+------------------+


I accidentally created duplicate records upon attempting to migrate
data from one server to another. You will have 2, 3 or more records
with every single field identical except for the ID. Best way to know
they're dumps is by "application_date" along with "unique_key".

View Replies !
Sql To Get Most Recent Records
How would I write the query for mySQL to get all the records in a table that
were written in tha last 10 minutes?

I have a timestamp field (fldTime) that automatically inserts the curent
time when the record is inserted, but I'm unsure how to write a query that
would only get records from the last 10 miniutes.

View Replies !

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