ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to create something like a dating website and I'm having a little trouble creating the search feature. I have two tables "Iam" and "Iamlookingfor." When user_one comes in to search for other members, he fills out Iam and Iamlookingfor. Here's where the problem comes in... When I making a query Iamlookingfor, I'll just go into the Iam database and pull out all the results that match. However, I also want to double check that all those results' Iamlookingfor match user_one's Iam. How can I pull out the results and then filter those results a second time?
I am trying to create something like a dating website and I'm having a little trouble creating the search feature. I have two tables "Iam" and "Iamlookingfor." When user_one comes in to search for other members, he fills out Iam and Iamlookingfor. Here's where the problem comes in... When I making a query Iamlookingfor, I'll just go into the Iam database and pull out all the results that match. However, I also want to double check that all those results' Iamlookingfor match user_one's Iam. How can I pull out the results and then filter those results a second time?
Hmm... I'm still really really new to MySQL so I'm not entirely sure . Iam and Iamlooking for are two separate tables (not columns), so I'm not sure how to get out of one table when I say FROM $tablename.
Maybe I can combine the two tables into a temp table or something...
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
So you create a query based in Iamlookingfor, you execute that query on Iam, and want to double check that the records you get returned from Iam are compliant to your query? That is what I read.
That is not loigical, a query is a query, and it returns what you ask, no need for a second check.
Or do you want to check if what Iam returns in the query matches with the Iamlookingfor record which was created by the same user returned from Iam? That sounds much more logical.
Or isn't it a requirement that every user in Iam has an entry in Iamlookingfor?
I would recommend a book "MySQL Crash Course". You need to normalize your database. You may have a clients table, with references to the address table, etc. Designing your database, normalizing it should be the first step before you begin working on the website.
Test it out using sql queries on some dummy entries. Then begin thinking about designing your website.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Quote:
Originally Posted by microchipper
Hmm... I'm still really really new to MySQL so I'm not entirely sure .
That was not completely clear. I am with jschiwal though. Learn SQL first, then design your database, then implement your web page. However, the mysql web site offers a tutorial-by-example. http://dev.mysql.com/doc/refman/5.0/en/tutorial.html
That is good enough to get you going working on databases.
I advice against using a GUI client for learning this stuff. Once you design a web page, you need to put in the SQL statements manually anyway. It is better if you learned it that way.
It is really simple, the learning curve is not steep. Over time you'll get a hold of creating really smart and really, really smart queries.
awesome. i'll definitely check out the guide. thanks for the suggestions.
i think i have also figured out how to do it. apparently, you can jump to other tables by adding a period... e.g. iam.userid and iamlookingfor.userid. is this right?
The mysql client uses the standard getline, so things like autocompletion and even [CTRL]-r work. You can enter the first few characters of a field and press tab.
If you use amarok at home, you can run it using a MySQL backend. Then you can practice on it's tables.
My favorite query is:
SELECT title, url
FROM podcastepisodes
WHERE isNew=1;
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.