maham
maham

Reputation: 223

How to update existing date and insert new date in a MySQL table

I have a little problem in updating date. My first table is

DONOR
donor-nic----username-----status
111----------ali----------available
222---------usman--------notavailable

My second table is

DONATION
donation_id------donor_nic-----date---
1----------------111----------2012/03/04
2---------------111-----------2012/06/07
3----------------111---------2012/07/08
4----------------222---------2012/03/03

Now I am editing profile like:

I want to do the following:

I don't know how to select all the dates of donor (111) and then match this date from the new date.

Upvotes: 0

Views: 200

Answers (1)

UltimateBlob
UltimateBlob

Reputation: 84

To see if there is already a specified date corresponding to a specific donor_nic, use

SELECT COUNT(date) > 0 FROM DONATION WHERE donor_nic="111" AND date="your date";

This should return true if "your date" is already specified for that donor_nic.

Upvotes: 1

Related Questions