I have databse having id and name field. In that I wanted to fetch random names from that database but the records which fetch in 1 st attempt wpuld not repeat in next attempt.
May be this can be done by using some stored precedure or something else i.e. i have to stored those values in some table and apply rules not pick values which is equal to that but i am not getting exact way of doing this.
so please do reply as early as possible.

Recommended Answers

All 4 Replies

At a time how many record you want to fetch?

One query knows nothing about another, so you would have to keep track. Bascially if you add a 'count' column, then you can sort by it, and select random from those. You would have to update the records, so a stored procedure is an option.

in single fetch i want 20 records to be fecthed.

"Just only fetching once in select statment and you want to remove that from next select".
I feel this is strange requirement.

But anyway just after select you need to insert same 20 records in some another table, to keep track that this 20 records shown.

Then your select will also reference that second table (where u insert records after selection) for latest query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.