I'm a beginner in Prolog and really need to solve this problem in Prolog's simplest syntax possible.
I have similar to 2 tables with different product information in Prolog like this:
product(id,company,value).
prod(prodid,date,color).
and the knowledge database is like this:
TABLE 1:
product(aa11zx, alfa, 1230).
product(bb22yz, beta, 5890).
product(cc11zx, alfa, 600).
product(dd22kx, beta, 730).
product(aa22vx, delta, 800).
TABLE 2:
prod(aa11, 1-2-2015, red).
prod(aa22, 1-7-2015, green).
prod(dd22, 1-4-2015, blue).
prod(bb22, 1-3-2015, blue).
prod(cc11, 1-3-2015, green).
The 2 tables have the 1st argument in common, but there are 2 problems I need to solve:
1st: I need a rule so that it understands that the 4 first characters in "id" in table 1 is the same as the 4 characters in "prodid" in table 2.
2nd: I need a rule / question where the system can join the 2 tables by their "product id" like it can be don in Excel with "vlookup" for example.
For example a final line of a join table should be:
product2(aa11, alfa, 1230,1-2-2015, red).
Can anyone help me ?
prodidin tableprodare always associated with the same row, you can as well just split them off to another column. PS. Consider using more descriptive table names? - user1812457