473,383 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Help in creating Table View

I had a table called 'FruitSaleList', that contains the following columns

sl.no, shop_id, fruitName, price, ....

I had also another table called 'FruitList' that contains the columns

shop_id, fruitName, salesManId, ....

the problem is 'FruitList' table doesn't contain a column like fruitId.

Let us assume there are following fruits are available in all shops

Apple
Banana
Cherry
Dates
Elderberry
Figs
Grapes
Jackfruit
Orange
(it is a lengthy list, around 50)

In some case I need to list the details of fruits after 'Grapes' from 'FruitSaleList'. That means I have to list the 'Jackfruit' and 'Orange' from 'FruitSaleList'.

I'm struggling to list these using a MySQL query in php.

If I create a table view(FruitDetails) like below then I will proceed as specified below

|FruitId|FruitName|
|1 |Apple |
|2 |Banana |
|3 |Cherry |
|4 |Dates |
|5 |Elderberry|
|6 |Figs |
|7 |Grapes |
|8 |Jackfruit |
|9 |Orange |

If it is possible then I will proceed by selecting the fruits after the fruitId 7. I can create virtual column or table but should avoid creating or alter table with real column or table.

If I haven't explained clearly, please let me know so that I will explain even more.

any help is appreciated. thanks in advance for your help.
Feb 13 '09 #1
2 2056
Atli
5,058 Expert 4TB
Hi.

So, your "FruitList" table is the one that actually lists the available fruits, and the "FruitSaleList" is the one that logs each fruit that is sold?

What is the Primary Key in the "FruitList" table? The name of the fruit?
If so, you should consider adding a integer ID field and use that as a PK instead. Using strings as PKs and FKs can get very messy and eat up a lot more recourses than is needed.

If you simply want to select items after a given value in alphabetical order, you could simply do:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `FruitList`
  2. WHERE `FruitName` > 'Grapes'
If the `FruitList` column is a string, this should give you every entry in the table that would be alphabetically sorted after 'Grapes'.

Is this what you are trying to do?
Feb 13 '09 #2
Thanks for helping me! Atli.

First I will answer, your questions,

[Atli.] your "FruitList" table is the one that actually lists the available fruits, and the "FruitSaleList" is the one that logs each fruit that is sold?

[thala] Absolutely, you are correct. "FruitList" is the table having unique fruits. Sales logs are available in "FruitSaleList" table.

[Atli.] What is the Primary Key in the "FruitList" table? The name of the fruit?

[thala] Yes, fruitName is the Primary Key. It's my bad time to have this.
-------------------------------
For explanation purpose, I have listed the fruits in alphabetical order. Actually it will not be in alphabetical. But when we query the FruitList table, it will list the fruits in alphabetical order. Hence, I hope, I can solve this problem using your precious idea\help.

Currently, I'm out of reach of MyDesktop, once I back to my work, I'll update the status soon.

Still, I have a doubt,
Is it possible or Is there a anyway to create table VIEW as FruitDetails as i explained in my post.

Atli, Thanks Once again for your help

thala.
Feb 14 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Keith | last post by:
I am having a problem creating a many-to-many-to-many type relationship. It works fine, but when I create a view to query it and test it, it does not generate the results I expected. Below...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
1
by: AvrilComplic8ed | last post by:
Hello there I wonder if you can help me. I am creating a loans system for a make-believe CD rental company, in Microsoft Access. I have 3 tables: CD details, Member Details, and Loan Details. I...
1
by: Julia | last post by:
Hello there. I have a question somewhat related to this topic, and I don't know where else to go. I hope somebody can help. I've created a database in access, that I'd like to share with less...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
13
by: Nagib Abi Fadel | last post by:
Is it possible to create a session variable for each user in Postresql ?? Thx
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.